Created
October 26, 2012 14:40
-
-
Save tobrien/3959201 to your computer and use it in GitHub Desktop.
Executing a SQLAlchemy Query against Akiban's Nested Resultsets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy_akiban import nested | |
stmt = nested([order.c.ordernum, order.c.timestamp]).\ | |
where(order.c.customer_id == customer.c.id) | |
stmt = select([customer.c.name, stmt.label('orders')]) | |
for customer_row in connection.execute(stmt): | |
print "customer name:", customer_row['name'] | |
for order_row in customer_row['orders']: | |
print "ordernum:", order_row['ordernum'] | |
print "timestamp:", order_row['timestamp'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment