I am having problems getting a list of table classes
using automap_base when the table has a composite primary key.
Not sure if this is the intended behaviour.

When I try to get the list tables classes using automap_base,
I only get tables 'a' and 'b' below and not table 'ab'.

This is using sqlalchemy 1.2.15.
This example was tested with sqlite3 but I get the same issue with Postgres

Here is the schema:

CREATE TABLE a (
  id INTEGER,
  PRIMARY KEY(id)
);


CREATE TABLE b (
  id INTEGER,
  PRIMARY KEY(id)
);


CREATE TABLE ab (
  a_id INTEGER NOT NULL,
  b_id INTEGER NOT NULL,
  FOREIGN KEY(a_id) REFERENCES a(id),
  FOREIGN KEY(b_id) REFERENCES b(id),
  PRIMARY KEY (a_id, b_id)
);



Base = automap_base()
engine = create_engine("sqlite:///mydb.db")
Base.prepare(engine, reflect=True)
print ('classes {}'.format(Base.classes.keys()))


-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to