I’m trying to figure out how to use python’s mysqldb. I can do my job with my current knownledge, but I want to use the best practices.
Should I close properly my cursor? Exiting the program isn’t close it autmatically? (Shouldn’t I expect the object destructor to do it anyway?)
Should I create new cursors for every query, or one cursor is enough for multiple different queries in the same DB?
Yes, you should. Explicit is better than implicit.
This depends on how you use this cursor. For simple tasks it is enough to use one cursor. For some complex application it is better to create separate cursor for each batch of SQL-queries.