Re: [sqlalchemy] Fun with Macros: PINQ to SQLAlchemy

2013-05-19 Thread Haoyi Li
...@zzzcomputing.comwrote: On May 17, 2013, at 9:37 AM, Haoyi Li haoyi...@gmail.com wrote: Hey All, I asked a few questions here a while ago to get help on a project, and thought it might be interesting to share the result of that project. PINQ to SQLAlchemy https://github.com/lihaoyi/macropy#pinq

[sqlalchemy] Fun with Macros: PINQ to SQLAlchemy

2013-05-17 Thread Haoyi Li
Hey All, I asked a few questions here a while ago to get help on a project, and thought it might be interesting to share the result of that project. PINQ to SQLAlchemy https://github.com/lihaoyi/macropy#pinq-to-sqlalchemy is a shameless clone of .NET's LINQ to SQL, using macros to perform the

[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 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

[sqlalchemy] Newbie Question: Aliases not Aliasing?

2013-05-07 Thread Haoyi Li
I posted this questionhttp://stackoverflow.com/questions/16410888/sqlalchemy-aliases-not-aliasingto StackOverflow, but thought this may be a better place to ask. I have the following sqlalchemy code: x = bbc.alias().c w = bbc.alias().cselect([func.distinct(x.region)]).where(

Re: [sqlalchemy] Newbie Question: Aliases not Aliasing?

2013-05-07 Thread Haoyi Li
([func.distinct(x.region)]).where(subq.as_scalar() 1) the WHERE 1 you're getting is because someselect 1 just comes out to Python True. On May 7, 2013, at 9:58 AM, Haoyi Li haoy...@gmail.com javascript: wrote: I posted this questionhttp://stackoverflow.com/questions/16410888