Close SQL cursors before committing a connection.
Cursor must always be closed before committing a connection
(http://stackoverflow.com/questions/9173073/python-mysql-mysqldb-testing-the-insert-function-its-not-adding-rows),
otherwise some DB client libraries will complain (specifically,
MySQLdb).
