SQLAlchemy
https://auth0.com/blog/sqlalchemy-orm-tutorial-for-python-developers/
1. Engines: db connection
Engines = manage Pools and Dialects.
engine = create_engine('postgresql://usr:pass@localhost:5432/sqlalchemy')creating an engine does not connect to the database instantly
Pool = to improve performance.
Opening and maintaining new connections is expensive
Easier management of # of connections simultaneously.
Dialects = adopt to different DB.
2. Session vs Connection
session = exec ORM sql query
connection = exec RAW sql query
3. Sessions: sync orm & db
modifications ORM tracked & applied to DB.
guarantee the database consistency.
4. Base: base class for all models
Last updated
Was this helpful?