anandology/datastore — Issue #2: Expose SQLAlchemy API to views?
Author: anandology
Created: 2011-11-23 12:52:12+00:00
State: open

How about exposing the sqlalchemy API for views instead inventing a new API?.

import sqlalchemy as sa

v = store.get_view("editions")
v.select(v.c.work=="/works/OL1M")
.limit(50)
.offset(100)
.order_by(sa.desc(v.c.publisher_year))
.execute()
.fetchall()

instead of:

store.query("editions", work="/works/OL1M", limit=50, offset=100, order_by="-publish_year")

Or should I support both? The query method just translates it to select.