pudo / dataset

Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.
https://dataset.readthedocs.org/
MIT License
4.76k stars 297 forks source link

FATAL: sorry, too many clients already #393

Closed liquidpeachy closed 2 years ago

liquidpeachy commented 2 years ago

I'm using the UPSERT in Dataset and when handling large amounts of data, I'm running into this error: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: sorry, too many clients already

Is there a way I can close the connection? or Something better?

Thank you.

pudo commented 2 years ago

Are you making a new db = dataset.connect() call very often? this seems odd if it's just dataset running against the instance. in any case you can call db.close() to dispose of all the connections opened by a db. Afterwards, the object becomes useless, of course.