2

I could not find a way to re-use a connection object. After executing conn.close() I still have the object in memory so there must be a way to re-use it. What's the best way to do it?

1
  • You don't have the connection to the database open anymore. What would you like to do with the connection object that doesn't involve the database? Commented Jul 17, 2013 at 14:27

1 Answer 1

3

From the connection class documentation:

close()

Close the connection now (rather than whenever del is executed). The connection will be unusable from this point forward; an InterfaceError will be raised if any operation is attempted with the connection

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

2 Comments

Does it mean that every time I create a new connection the old one stays in memory?
Not if you assign the new connection to the same variable; then the object (and memory) gets overwritten. What's the worry though? A closed connection object won't exhaust your memory.

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.