Neat, thank you Rob. --- Rob Lohman <[EMAIL PROTECTED]> wrote:
> You don't need to insert the primary key at all, so > don't insert a NULL. See the test below: > > D:\SQLite>sqlite3 mltest.db > SQLite version 3.2.1 > Enter ".help" for instructions > sqlite> CREATE TABLE projects(project_id INTEGER > PRIMARY KEY, cip_number); > sqlite> INSERT INTO projects (cip_number) VALUES > (11); > sqlite> INSERT INTO projects (cip_number) VALUES > (15); > sqlite> INSERT INTO projects (cip_number) VALUES > (231); > sqlite> INSERT INTO projects (cip_number) VALUES > (0); > sqlite> SELECT * FROM projects; > 1|11 > 2|15 > 3|231 > 4|0 > sqlite> > > Rob > > ----- Original Message ----- > From: "Dan McDaniel" <[EMAIL PROTECTED]> > To: <sqlite-users@sqlite.org> > Sent: Saturday, November 05, 2005 5:16 AM > Subject: Re: [sqlite] can' t get autoincrement to > work > > > Thanks Clay > > I downloaded version 3-2-7 (Windows xp pro) for both > my home and office system. I am working through > pysqlite > and have set up all the tables through Python with > table creation statements like this: > cur.execute("CREATE TABLE projects(project_id > INTEGER > PRIMARY KEY, \ > cip_number INTEGER, project_name > VARCHAR(30), project_area INTEGER, \ > original_budget INTEGER, start_date > date, > end_date date)") > > I have tried adding the word 'AUTOINCREMENT' after > the > 'PRIMARY KEY PHRASE' with no luck. > > I have tried very simple tables. When I do and > insert > with a NULL value in the Primary Key column, the > database accepts the insert with no complaint or > errors. > When I retrive the data, no results (rows) are > returned for the values were NUll was inserted; only > where I > have explicitly listed a number in the PK field do > I > get any Results. > > I am going to do further experiments tomorrow by > downloading to my Linux box. All of the tables have > been created from within Python2-4, none on the > sqlite command line, so maybe that has something to > do > with it. > > > I am hoping that the additional info I have given > helps to suggest what's going on. > > Thanks again Clay > DAn > > --- Clay Dowling <[EMAIL PROTECTED]> wrote: > > > Dan McDaniel wrote: > > > > >I have not been able to get autoincrement to > work. > > I > > >downloaded latest version several days ago to > home > > and > > >office machine. Can not get it to work on either. > > >Please help. > > > > > > > > Show us your DDL for the table. In general the > > field should be an > > integer primary key. If you do that you'll get > auto > > incrementing keys > > by default. If you tack auto_increment on to it > > you'll get slightly > > different behavior in the selection of keys. > > > > Clay Dowling > > > > > > > __________________________________ > Start your day with Yahoo! - Make it your home page! > > http://www.yahoo.com/r/hs > __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com