Have you looked at SQLSoup ? This library already does exactly what you're looking for.
https://sqlsoup.readthedocs.org/en/latest/ > For the most part, I have this working. However, the example in the gist > shows that: > > len(g.cpgIslandExt.all()) != g.cpgIslandExt.count() What does your SQL echo output say? Looking at the queries (and the rows returned, if you use echo='debug') will illustrate what's being sent. A typical reason why all() returns fewer rows is when the query returns duplicate primary key identities - returned objects are uniqued on identity as they are received. The fact that the "name" column is being hardcoded in your base model as the sole "primary key" for all mappings is the likely cause of this even being possible. The reflection process already knows how to yield the primary key constraints defined on each table so you'd best rely upon that. -- 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 http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.