On Wed, Dec 9, 2020 at 11:49 AM Larry Martell <[email protected]> wrote: > > On Wed, Dec 9, 2020 at 11:44 AM Larry Martell <[email protected]> wrote: > > > > When I run sqlacodegen on my DB it creates classes for most of the > > tables, but for some it creates only Table objects. I don't see any > > rhyme or reason as to why it does this for some. How can I get to > > generate classes for all the tables? > > I found this: > https://stackoverflow.com/questions/34675604/sqlacodegen-generates-mixed-models-and-tables/35916967 > that says it generates Table objects if there is no PK. But the ones > it generated Table objects for do have PKs, e.g.: > > t_BusinessAreaContact = Table( > 'BusinessAreaContact', metadata, > Column('businessAreaID', > ForeignKey('BusinessArea.businessAreaID'), primary_key=True, > nullable=False), > Column('contactEmail', ForeignKey('Contact.contactEmail'), > primary_key=True, nullable=False) > )
Ah, seeing this now: It will only form model classes for tables that have a primary key and are not association tables A table is considered an association table if it satisfies all of the following conditions: has exactly two foreign key constraints all its columns are involved in said constraints -- 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/CACwCsY4LDnEjmhSkN3c35S69MFVpNfCxRQb%3DQOdgkrWXDVbQNg%40mail.gmail.com.
