On 11/07/2022 1:19 am, Mike Bayer wrote:
background on mapping ORM classes to reflected tables is at https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#mapping-declaratively-with-reflected-tables <https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#mapping-declaratively-with-reflected-tables> and there are three general methods depending on your needs.  DeferredReflection is oriented towards explicit class setup, and automap is oriented towards "just give me pre-made classes", with much less ability to customize how the classes look and behave.

if you were using automap and needed to override PK for this one class:

from sqlalchemy.ext.automap import automap_base
from sqlalchemy import create_engine, Integer, Column

Base = automap_base()



class MyTable(Base):
     __tablename__ = 'my_table'

     userID = Column(Integer, primary_key=True)
     groupID = Column(Integer, primary_key=True)

It's the setting of both as primary_key that does it?

Thank you

Carl

--
SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/258f6797-ed5a-18c1-6fba-a05b538151d1%40bl.echidna.id.au.

Reply via email to