Created
June 17, 2016 14:06
-
-
Save absent1706/d2520be2474ec61cb21c8f93e58f3d62 to your computer and use it in GitHub Desktop.
sqlalchemy Laravel/Rals/Django-like find() method
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
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