SQLAlchemy
Jump to navigation
Jump to search
Pinboard: https://pinboard.in/u:kittell/t:sqlalchemy/
Connecting
- create_engine: https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine
- URL.create: https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.engine.URL.create
# Connecting to a database and starting a session from sqlalchemy import create_engine from sqlalchemy.orm import Session from sqlalchemy.engine import URL connection_url = URL.create( drivername='xxx', username='xxx', password='xxx', host='xxx', database='xxx', port='xxx', query={ "driver": "xxx", }, ) q = (xxx) engine = create_engine(connection_url) with Session(engine) as session: results = session.execute(q).all()