[sqlalchemy] Re: obtaining a table schema

2009-04-29 Thread Mike Conley
Look at the primary_key attribute of the table instance. uu = Table('u',meta, Column('id',Integer,primary_key=True), Column('data',Integer)) print uu.primary_key.columns ['u.id'] Mike On Tue, Apr 28, 2009 at 7:53 PM, Paul Rigor (gmail) paulri...@gmail.comwrote: Hi gang,

[sqlalchemy] Re: obtaining a table schema

2009-04-29 Thread Giovanni Dall'Olio
On Apr 29, 1:53 am, Paul Rigor (gmail) paulri...@gmail.com wrote: Hi gang, I've recently started using sqlalchemy, so hopefully this isn't a stupid question... I was wondering whether there was an easy way to obtain a particular table's schema if one is using just bare connection (ie, not

[sqlalchemy] Re: obtaining a table schema

2009-04-29 Thread Paul Rigor (gmail)
Thanks Mike, Like I mentioned for my particular application, I won't be using the usual ORM but just the bare engine/connection. I'll just be provided with a table name and a connection. I did a little bit of research but was only able to figure out how to obtain the primary for a mysql database

[sqlalchemy] Re: obtaining a table schema

2009-04-29 Thread Paul Rigor (gmail)
Thanks, FYI that link you sent was very useful. For anyone else interested, here's my code snippet. I've tested this with both mysql and sqlite databases. def get_primary_key(tablename,*args,**kwargs): from sqlalchemy import MetaData metadata = MetaData(*args,**kwargs) # uri