mysql - Do I need to close a database connection in a short python script? -


What dragon (version 2.7, 3.3) closes the database connection immediately after a program finishes?

For example:

  Import MySQLdb conn = sqlite3.connect (host = "localost", user = "adam", password = "12345", db = "My_db") c = conn.cursor () c.execute ('SELECT * FROM MY_TABLE' '') cur.close () # Do I really need it? Conn.close () # Do I really need it?   

If I could have a problem with shutting down the connection to run this script again once again?

ps Yes, I know that the best practice is to stop all the resources.

As you have said that you should close the connection to your code explicitly < P> SQLite will return any open transaction for example.

In addition to this I have read somewhere you can use the statement with when you are using MYSQL, Google may be worth googling.

Comments

Popular posts from this blog

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

c++ - Redefined variable in the other module -

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -