Skip to content

Instantly share code, notes, and snippets.

@absent1706
Created June 17, 2016 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save absent1706/d2520be2474ec61cb21c8f93e58f3d62 to your computer and use it in GitHub Desktop.
Save absent1706/d2520be2474ec61cb21c8f93e58f3d62 to your computer and use it in GitHub Desktop.
sqlalchemy Laravel/Rals/Django-like find() method
def find(db, id_): # db is better to be global IMHO
db.query(self.__class__).filter(self.__class__.__mapper__.primary_key[0] == id_).one()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment