The spec says, in short, that when .fetchone() returns None, that means that the cursor has reached the end of the result set. Executing a query that returns one row will produce a result set that will yield one row, and then reach the end. Executing multiple queries will queue up multiple result sets, and they will be traversed in order.
If you execute two queries that each return one row, calling .fetchone() four times will return: [result1, None, result2, None]. Here's a thing which might be edifying: http://bazaar.launchpad.net/~habnabit/oursql/master/view/head:/oursqlx/cursor.pyx#L176 -- You received this bug notification because you are a member of Agesys Team, which is subscribed to oursql. https://bugs.launchpad.net/bugs/718860 Title: Call to fetchone after LAST_INSERT_ID() does not clear cursor Status in oursql: Invalid Bug description: Client: mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i686) using readline 5.1 Server: Server version: 5.0.77 Source distribution Python 2.7 oursql-0.9.2-py2.7-linux-i686 When calling LAST_INSERT_ID() cursor.fetchone() must be called twice, or else a new call to cursor.fetchone() will return None: >>> cursor.execute("INSERT INTO users (username) VALUES ('test')") >>> cursor.execute("SELECT LAST_INSERT_ID()") >>> print cursor.fetchone() {'LAST_INSERT_ID()': 7L} >>> cursor.execute("INSERT INTO users (username) VALUES ('test2')") >>> cursor.execute("SELECT LAST_INSERT_ID()") >>> print cursor.fetchone() Expected: {'LAST_INSERT_ID()': 8L} Actual: None _______________________________________________ Mailing list: https://launchpad.net/~agesys-dev Post to : [email protected] Unsubscribe : https://launchpad.net/~agesys-dev More help : https://help.launchpad.net/ListHelp

