Re: [sqlite] Problem with inserting and integer primary key

2008-10-16 Thread John Belli
On Wed, 15 Oct 2008 12:43:00 -0400, "Igor Tandetnik"
<[EMAIL PROTECTED]> wrote:

>Be aware that, in order to create a column that aliases ROWID (and thus 
>has special properties in SQLite, such as getting an automatically 
>assigned unique integer) it has to be spelled precisely INTEGER PRIMARY 
>KEY.

Note that INT PRIMARY KEY is not sufficient, which may be useful.


JAB
-- 
John A. Belli
Software Engineer
Refrigerated Transport Electronics, Inc.
http://www.rtelectronics.com

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problem with inserting and integer primary key

2008-10-15 Thread Igor Tandetnik
Karl Lautman <[EMAIL PROTECTED]> wrote:
> So, I create a table as follows:
>
> CREATE TABLE IF NOT EXISTS Lists (
> wID integer,
> ltitle text,
> llink text,
> units text,
> date text,
> ListsID integer,
> new integer
> , CONSTRAINT Lists_pk PRIMARY KEY (ListsID))

Be aware that, in order to create a column that aliases ROWID (and thus 
has special properties in SQLite, such as getting an automatically 
assigned unique integer) it has to be spelled precisely INTEGER PRIMARY 
KEY. Doing it the way you show, with a CONSTRAINT clause, won't do the 
trick. Make it

CREATE TABLE IF NOT EXISTS Lists (
wID integer,
ltitle text,
llink text,
units text,
date text,
ListsID integer primary key,
new integer);

Scott Baker already addressed the rest of your problem.

Igor Tandetnik 



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problem with inserting and integer primary key

2008-10-15 Thread Scott Baker
On 10/15/2008 09:27 AM, Karl Lautman wrote:
> To insert data I do (this is in Python):
>
>
>
> x = dcur.execute('insert into Lists values (?, ?, ?, ?, ?, ?)', (123,
> 'YouTube Videos','http://www.youtube.com', 'views', '10/14/08', 4))

Just add NULL for the primary key value. SQLite will autopopulate the 
number, but you have to tell it to do it. Just because it's a primary key 
doesn't mean you can't ALSO provide it a value (like 73). So you have to 
tell it to pick one itself by using NULL.

-- 
Scott Baker - Canby Telcom
RHCE - System Administrator - 503.266.8253
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users