SQLite

gordyt gordyt at gmail.com
Fri Oct 3 09:25:49 EDT 2008


Howdy Matthias!

The delete operation will set the rowcount member of your cursor.
Let's assume you have an sqlite3 database with a table called 'test'
with an id column.  It does have a record with id=1.  It does not have
a record with id=2.

>>> import sqlite3
>>> connection = sqlite3.connect('test.sqlite3')
>>> cursor = connection.cursor()
>>> cursor.execute('delete from test where id=1')
<sqlite3.Cursor object at 0x7f3450>
>>> print cursor.rowcount
1
>>> cursor.execute('delete from test where id=2')
<sqlite3.Cursor object at 0x7f3450>
>>> print cursor.rowcount
0
>>> cursor.close()
>>> connection.close()


--gordy



More information about the Python-list mailing list