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 is a shameless clone of .NET's LINQ to SQL, using macros to perform the lifting of code into a SQL query. It lets you write code like this:
# Countries with a land area greater than 10 million square kilometers
print query%((x.name, x.surface_area) for x in db.country if x.surface_area > 10000000)
# [(u'Antarctica', Decimal('13120000.0000000000')), (u'Russian Federation', Decimal('17075400.0000000000'))]Where the whole thing gets translated into a SQLAlchemy expression language "select" query and shipped over to the database. It basically relies entirely on SQLAlchemy's expression language, using macros to perform a very shallow translation from generator-comprehensions into the expression language's "select" and "where" clauses, as well as nicely binding the tables (e.g. db.country) to properly-scoped names.
I thought it may be of interest to some people; you guys clearly put a lot of thought into the expression language (it's pretty great!) and I think its cool how little work was necessary (~80 LOC) to write a macro that removes much of the remaining syntactic boilerplate.
Hope someone found this interesting!
-Haoyi