In the Python documentation (http://docs.python.org/library/sqlite3.html?highlight=sqlite#using-shortcut-methods) it says: "Using the nonstandard execute(), executemany() and executescript() methods of the Connection object, your code can be written more concisely because you don't have to create the (often superfluous) Cursor objects explicitly. Instead, the Cursor objects are created implicitly and these shortcut methods return the cursor objects. This way, you can execute a SELECT statement and iterate over it directly using only a single call on the Connection object."
Here is pseudo-code: db = sqlite.connect(path, ...) cursor = db.cursor() # normal method def doDBStuff(): cursor = db.cursor() cursor.execute(somestatement) or cursor.executemany(somestatement) or cursor.executescript(somestatement) cursor.close() return # suggested method def doDbStuffCorrectly(): cursor.execute(somestatement) or cursor.executemany(somestatement) or cursor.executescript(somestatement) return Does the implicit method close the cursor? This would be important in a multi-user environment with read/write access.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor