Posts

Showing posts with the label sqlalchemy

SQLAlchemy - work with connections to DB and Sessions (not clear behavior and part in documentation)

SQLAlchemy - work with connections to DB and Sessions (not clear behavior and part in documentation) I use SQLAlchemy (really good ORM but documentation is not clear enough) for communicating with PostgreSQL Everything was great till one case when postgres "crashed" cause of maximum connection limits was reached: no more connections allowed (max_client_conn) . That case makes me think that I do smth wrong. After few experiments I figure out how not to face that issue again, but some questions left Below you'll see code examples (in Python 3+, PostgreSQL settings are default) without and with mentioned issue, and what I'd like to hear eventually is answers on following questions: making connection to DB : from sqlalchemy.pool import NullPool # does not work without NullPool, why? def connect(user, password, db, host='localhost', port=5432): """Returns a connection and a metadata object""" url = 'postgresql://{}:{}@{}:{...