Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save inklesspen/226938 to your computer and use it in GitHub Desktop.

Select an option

Save inklesspen/226938 to your computer and use it in GitHub Desktop.
def session_mapper(scoped_session):
def mapper(cls, *arg, **kw):
cls.query = scoped_session.query_property()
return sqla_mapper(cls, *arg, **kw)
return mapper
mapper = session_mapper(Session)
# Then, you can do like Book.query.get(id) or User.query.filter_by(username="bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment