can' t get autoincrement to work

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

can' t get autoincrement to work

dannykmcdaniel
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.
dan


               
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: can' t get autoincrement to work

Puneet Kishor

On Nov 4, 2005, at 9:18 PM, 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.
>

no one can help unless you tell --

what version you downloaded,

what you did to make autoincrement work,

how you know it doesn't work,

what error messages you received, if any,

what platform you are working on.

No one can guess these things for you, so how about disclosing them
right up-front.



--
Puneet Kishor

Reply | Threaded
Open this post in threaded view
|

Re: can' t get autoincrement to work

Clay Dowling
In reply to this post by dannykmcdaniel
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
Reply | Threaded
Open this post in threaded view
|

Re: can' t get autoincrement to work

dannykmcdaniel
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: can' t get autoincrement to work

dannykmcdaniel
Autoincrement works with sqlite command line but still
doesn't through pysqlite from Python

--- Dan McDaniel <[hidden email]> wrote:

> 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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: can' t get autoincrement to work

Rob Lohman
In reply to this post by dannykmcdaniel
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" <[hidden email]>
To: <[hidden email]>
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: can' t get autoincrement to work

dannykmcdaniel
Neat, thank you Rob.

--- Rob Lohman <[hidden email]> 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" <[hidden email]>
> To: <[hidden email]>
> 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 <[hidden email]> 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