0

Assuming that no statements to close the connection are made before my script ends and no exception is encountered before closing the connection, does the database's connection stay open?

I'm connecting to the database programmatically via Python Psycopg2 and via Java JDBC4 driver.

2
  • 1
    From where do you connect to your database? Language? Commented Apr 20, 2011 at 8:08
  • 1
    You need to be more specific. Are you using a query tool or doing this from code? Provide any relevant code samples. Commented Apr 20, 2011 at 8:09

1 Answer 1

1

Not entirely sure what you want exactly, but let's try:

  1. You can see the connections that exist at any time with PGAdmin or this SQL command

    SELECT * FROM pg_stat_activity;

    It should be fairly simple to spot when - for your specific use case - the connection closes.

  2. If an SQL query is running at the time you close a connection, I think it will run to completion, ie the backend serving it will remain alive, even if the connection is closed from the client side.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.