-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dennis Cote wrote: > It is probably a bug (or a design decision) in the apsw wrapper.
The cursor object in apsw wraps a prepared statement. Since the cursor gets reused the earlier results are no longer available: cursor.execute("select * from numbers") ... cursor.execute("delete from numbers where no=5") An equivalent C program would be: sqlite3_stmt* s; sqlite3_prepare(db, "select * from numbers", -1, &s, 0); ... sqlite3_step to get some results sqlite3_prepare(db, "delete from numbers where ..", -1, &s, 0); // same s so earlier statement clobbered and // latter one doesn't return anything The underlying design decision was to mirror the way SQLite works - ie reactively getting each row an on requested basis rather than getting them all proactively up front. In Python you can get proactively all items from an iterator using 'list', so this would work (using 'iter' to then turn the list back into an iterator): import apsw conn=apsw.Connection("data") cursor = conn.cursor() res = iter( list( cursor.execute("select * from numbers") ) ) # here res.next() # (1,) res.next() # (2,) res.next() # (3,) cursor.execute("delete from numbers where no=5") res.next() # (4,) Alternatively the "delete" statement can be done with a different cursor so that the earlier one is not clobbered: cursor2=conn.cursor() cursor2.execute("delete from numbers where no=5") Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIgTdkmOOfHg372QQRAq2/AKDKoUdG2hKJ1SlQoQC1jqxI2nIwEACfYWgH arrTotpA6qqwhqrKPEfCvKs= =m1fG -----END PGP SIGNATURE----- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users