I've been accessing a postgreSQL database with python3 and psycopg2.
I encountered an error that implied I had open connections. When I ran SELECT * FROM pg_stat_activity
a bunch of connections under my username came up. They all have a state of 'idle', and many of them show a "query" value that I never ran (ex: select 1
, show search_path
).
I've seen this on how to close them automatically. And, I've also read that using pg_terminate_backend
is dangerous and will cause the database to restart. How do I close these connections naturally with python3 or SQL? It is a company production database, so restarting it or being the admin isn't an option. Let me know if I must be an admin to solve this issue.