[sqlalchemy] Remove repetition of engine in queries

2013-05-08 Thread Haoyi Li
I have code that looks like this engine = create_engine(sqlite://) ...initialize stuff... metadata = sqlalchemy.MetaData(engine) metadata.reflect() class Db: pass db = Db() for table in metadata.sorted_tables: setattr(db, table.name, table) query = select([db.bbc.c.name]).where(

Re: [sqlalchemy] Remove repetition of engine in queries

2013-05-08 Thread Michael Bayer
On May 8, 2013, at 9:45 AM, Haoyi Li haoyi...@gmail.com wrote: It creates an in memory database, initializes it, reflects to get its tables out, and then performs some queries. One thing that's I've noticed is the fact that I have to specify the engine twice: once at the top, when I

Re: [sqlalchemy] Remove repetition of engine in queries

2013-05-08 Thread Haoyi Li
I see that, thanks for the pointer! On Wed, May 8, 2013 at 10:22 AM, Michael Bayer mike...@zzzcomputing.comwrote: On May 8, 2013, at 9:45 AM, Haoyi Li haoyi...@gmail.com wrote: It creates an in memory database, initializes it, reflects to get its tables out, and then performs some queries.