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

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -