Search code snippets, questions, articles...

Get first record Sqlalchemy

Get the very first record from a model or table using the Sqlalchemy query.
#Get vey first record from a table which has id grater than 10
session.query(User).filter(User.id > 10).first()

You can get the very first record from a table using the Sqlalchemy query using the .first() method.

Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet