sqlite autoincrement of primary key

Tim Harig usernet at ilthio.net
Mon Nov 29 13:28:22 EST 2010


On 2010-11-29, tinauser <tinauser at libero.it> wrote:
> '''
> INSERT INTO 'foo' VALUES (?,?)
> '''
> ,('NULL','yyy'))

s/'NULL'/None/

> I get a datatype mismatch error.

The sqlite module is smart enough to convert between Python types and
Sqlite types.  If you pass it 'NULL' it thinks you are passing it a string.
Python uses None in much the same way that databases use NULL, so the
module converts None to 'NULL' and vise versa.



More information about the Python-list mailing list