Re: sqlite autoincrement of primary key

2010-11-29 Thread tinauser
On Nov 29, 10:49 pm, "D'Arcy J.M. Cain" wrote: > On Mon, 29 Nov 2010 19:11:18 + (UTC) > > Tim Harig wrote: > > >   INSERT INTO foo (name) VALUES ('xxx') > > > > That's the standard SQL way. > > > Yes, it works; but, the OP asked specifically to be able to enter all of > > the field values, in

Re: sqlite autoincrement of primary key

2010-11-29 Thread Tim Harig
On 2010-11-29, D'Arcy J.M. Cain wrote: > On Mon, 29 Nov 2010 19:11:18 + (UTC) > Tim Harig wrote: >> > INSERT INTO foo (name) VALUES ('xxx') >> > >> > That's the standard SQL way. >> >> Yes, it works; but, the OP asked specifically to be able to enter all of >> the field values, including t

Re: sqlite autoincrement of primary key

2010-11-29 Thread D'Arcy J.M. Cain
On Mon, 29 Nov 2010 19:11:18 + (UTC) Tim Harig wrote: > > INSERT INTO foo (name) VALUES ('xxx') > > > > That's the standard SQL way. > > Yes, it works; but, the OP asked specifically to be able to enter all of > the field values, including the autoincrement field. You're right, I missed th

Re: sqlite autoincrement of primary key

2010-11-29 Thread Alan Meyer
On 11/29/2010 1:12 PM, tinauser wrote: Dear List I'm writing an application that has to create and populate an SQLite database. I'm doing pretty well, but now I'm facing a problem I can not solve. I create a table with a primary key autoincrement, something like sqlcmd="CREATE TABLE foo (id INT

Re: sqlite autoincrement of primary key

2010-11-29 Thread tinauser
On Nov 29, 7:28 pm, Tim Harig wrote: > On 2010-11-29, tinauser 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 y

Re: sqlite autoincrement of primary key

2010-11-29 Thread Tim Harig
On 2010-11-29, D'Arcy J.M. Cain wrote: > On Mon, 29 Nov 2010 13:19:19 -0500 > Mel wrote: >> tinauser wrote: >> '''INSERT INTO foo VALUES (NULL, ?)''' > > Does this work in SQLite: > > INSERT INTO foo (name) VALUES ('xxx') > > That's the standard SQL way. Yes, it works; but, the OP asked specif

Re: sqlite autoincrement of primary key

2010-11-29 Thread D'Arcy J.M. Cain
On Mon, 29 Nov 2010 13:19:19 -0500 Mel wrote: > tinauser wrote: > '''INSERT INTO foo VALUES (NULL, ?)''' Does this work in SQLite: INSERT INTO foo (name) VALUES ('xxx') That's the standard SQL way. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/

Re: sqlite autoincrement of primary key

2010-11-29 Thread Tim Harig
On 2010-11-29, tinauser 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. Pyth

Re: sqlite autoincrement of primary key

2010-11-29 Thread John Bokma
tinauser writes: > however, if in python i try to execute a script like: > > cur.execute( > ''' > INSERT INTO 'foo' VALUES (?,?) > ''' > ,('NULL','yyy')) ,(None, 'yyy')) Or use VALUES(NULL, ?) as suggested in another post. -- John Bokma

Re: sqlite autoincrement of primary key

2010-11-29 Thread Mel
tinauser wrote: > Normally, the sqlite command that works would be > > INSERT INTO 'foo' VALUES (NULL, 'yyy' ) > > however, if in python i try to execute a script like: > > cur.execute( > ''' > INSERT INTO 'foo' VALUES (?,?) > ''' > ,('NULL','yyy')) > > I get a datatype mismatch error. > > Ha

sqlite autoincrement of primary key

2010-11-29 Thread tinauser
Dear List I'm writing an application that has to create and populate an SQLite database. I'm doing pretty well, but now I'm facing a problem I can not solve. I create a table with a primary key autoincrement, something like sqlcmd="CREATE TABLE foo (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT