Switching Databases

Carsten Haese carsten.haese at gmail.com
Mon Nov 23 16:08:36 CET 2009

Victor Subervi wrote:
> On Mon, Nov 23, 2009 at 9:17 AM, Carsten Haese <carsten.haese at gmail.com
> <mailto:carsten.haese at gmail.com>> wrote:
>     You thought you did, but did you? The code snippet above doesn't show
>     any code that closes a database connection.
> Would you be so kind as to tell me exactly what code *does* close a
> database, then?

Assuming that db is the name of the database connection object,
db.close() closes the connection.

> That would solve this handily. Other than than, when I
> am at a computer when I can provide you error messages, I will, but it
> all boils down to that code that closes the database, doesn't it?

Only if your diagnosis of the problem is accurate, and I have my doubts
about that. A MySQL database server is perfectly capable of entertaining
multiple simultaneous connections, so I find it unlikely that your
inability to open a second connection is caused by not closing the first

As I said, the best way we can help you is if you copy the actual error
message so that we may diagnose the actual problem and suggest a
solution that fixes the problem.

Carsten Haese

More information about the Python-list mailing list