Reputation: 574
I'm creating a bunch of simple tables like this:
newtable = Table("mytable", metadata, Column('user_id', Integer), Column('value', Integer))
I know I can access the user_id column like newtable.c.user_id. However, the name of this column differs among tables, e.g. 'program_id' or 'credit_id'. I want to be able to create the table such that I can access this first column by a generic key, say 'id', and then use the column attributes to get its actual name, i.e.
column_name = newtable.c.id.name
and then column_name = 'user_id'.
How do I modify my table creation to do this? I know how to do it if I'm using declarative_base in the ORM, but I haven't been able to find anything in the docs to do this if I'm just using the Expression Language.
Upvotes: 0
Views: 182