Обсуждение: I'm very confused.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there, I think that this may be my first post to this list so be gentle. I'm having a very strange problem (to me) and I hope that someone can shed some light on what I'm not seeing. I created a database and table from the command line using: sudo su postgres createdb test That worked fine and created the stated table. I then logged in using: sudo su postgres psql test Again, that worked fine. I created a table from the prompt using: create table users (userID serial, userName varchar(32), firstName varchar(32), lastName varchar(64), email varchar(128)); The table was successfully created. So good so far. Don't mind the values of the varchar's; this is purely for testing. I then added a primary key to the table using: alter table users add primary key (userId); Again, it worked. Here's where it starts to get weird. I inserted data into the table using: insert into users (username, firstName, lastName, email) values ('bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com'); It went in properly and I was able to select the inserted data without any problems (select * from users;). I then wrote a python script to insert and select data from the table. The script is able to insert and retrieve data without any problems...*but*...from the console I can't retrieve any of the records inserted by the script. Records that are entered at the console show up when I do a select with the script, but not the other way around. I have tried to the RTFM as much as possible, but I'm still lost as to why while accessing the same table I can't access the data manipulated by the script. I don't know if it has anything to do with tablespaces or what, but I'm really starting to get frustrated. I'm from a MySQL background and I'm completely stumped as to how you can, through a script, insert data into a database *created at the console* and not be able to select that data from the console. I know it's there taking up space on my machine, and I can select it from the script, but I can't manipulate it in any way outside of that. Any thoughts? - -- Brant Fitzsimmons brant@bfcomputerconsulting.com - ------------------------------------------------------------------- "Strange times are these in which we live when the old and the young are taught falsehoods in the schools of learning. And the one man that dares to tell the truth is called at once a lunatic and a fool." -Plato -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFrcVlDpzwx2t8E5gRAv6BAJ9It2xCVv+f+iYridluQxQav7pv4wCffNQX fqy/kGwKA1RCcWkmuc3r8T4= =7liR -----END PGP SIGNATURE-----
On Tuesday 16 January 2007 22:42, Brant Fitzsimmons <brant@bfcomputerconsulting.com> wrote: > Records that are entered at the console show up when I do a select > with the script, but not the other way around. I have tried to the > RTFM as much as possible, but I'm still lost as to why while > accessing the same table I can't access the data manipulated by the > script. I don't know if it has anything to do with tablespaces or > what, but I'm really starting to get frustrated. Is the script starting a transaction and not committing it? If so, the changes it makes will not be visible to other processes. psql by default operates in auto-commit mode, every statement is committed on completion. If this is not the case, I would have to say you are not in fact working on the same table, somehow. -- "The best we can hope for concerning the people at large is that they be properly armed." -- Alexander Hamilton
Please attach a snippet of your python script and lets see what are you doing there. That might make things easy. Jas On 1/17/07, Brant Fitzsimmons <brant@bfcomputerconsulting.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi there, > > I think that this may be my first post to this list so be gentle. > > I'm having a very strange problem (to me) and I hope that someone can > shed some light on what I'm not seeing. > > I created a database and table from the command line using: sudo su > postgres createdb test > > That worked fine and created the stated table. > > I then logged in using: sudo su postgres psql test > > Again, that worked fine. > > I created a table from the prompt using: create table users (userID > serial, userName varchar(32), firstName varchar(32), lastName > varchar(64), email varchar(128)); > > The table was successfully created. So good so far. Don't mind the > values of the varchar's; this is purely for testing. > > I then added a primary key to the table using: alter table users add > primary key (userId); > > Again, it worked. > > Here's where it starts to get weird. > > I inserted data into the table using: insert into users (username, > firstName, lastName, email) values ('bfitzsimmons', 'Brant', > 'Fitzsimmons', 'brant@bfcomputerconsulting.com'); > > It went in properly and I was able to select the inserted data without > any problems (select * from users;). > > I then wrote a python script to insert and select data from the > table. The script is able to insert and retrieve data without any > problems...*but*...from the console I can't retrieve any of the > records inserted by the script. > > Records that are entered at the console show up when I do a select > with the script, but not the other way around. I have tried to the > RTFM as much as possible, but I'm still lost as to why while accessing > the same table I can't access the data manipulated by the script. I > don't know if it has anything to do with tablespaces or what, but I'm > really starting to get frustrated. > > I'm from a MySQL background and I'm completely stumped as to how you > can, through a script, insert data into a database *created at the > console* and not be able to select that data from the console. I know > it's there taking up space on my machine, and I can select it from the > script, but I can't manipulate it in any way outside of that. > > Any thoughts? > > - -- > Brant Fitzsimmons > brant@bfcomputerconsulting.com > - ------------------------------------------------------------------- > "Strange times are these in which we live when the old and the > young are taught falsehoods in the schools of learning. And the one > man that dares to tell the truth is called at once a lunatic and > a fool." > -Plato > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.3 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFFrcVlDpzwx2t8E5gRAv6BAJ9It2xCVv+f+iYridluQxQav7pv4wCffNQX > fqy/kGwKA1RCcWkmuc3r8T4= > =7liR > -----END PGP SIGNATURE----- > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings >
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Brant Fitzsimmons wrote: > Hi there, > > I think that this may be my first post to this list so be gentle. > > I'm having a very strange problem (to me) and I hope that someone > can shed some light on what I'm not seeing. > > I created a database and table from the command line using: sudo su > postgres createdb test > > That worked fine and created the stated table. > > I then logged in using: sudo su postgres psql test > > Again, that worked fine. > > I created a table from the prompt using: create table users (userID > serial, userName varchar(32), firstName varchar(32), lastName > varchar(64), email varchar(128)); > > The table was successfully created. So good so far. Don't mind > the values of the varchar's; this is purely for testing. > > I then added a primary key to the table using: alter table users > add primary key (userId); > > Again, it worked. > > Here's where it starts to get weird. > > I inserted data into the table using: insert into users (username, > firstName, lastName, email) values ('bfitzsimmons', 'Brant', > 'Fitzsimmons', 'brant@bfcomputerconsulting.com'); > > It went in properly and I was able to select the inserted data > without any problems (select * from users;). > > I then wrote a python script to insert and select data from the > table. The script is able to insert and retrieve data without any > problems...*but*...from the console I can't retrieve any of the > records inserted by the script. > > Records that are entered at the console show up when I do a select > with the script, but not the other way around. I have tried to the > RTFM as much as possible, but I'm still lost as to why while > accessing the same table I can't access the data manipulated by the > script. I don't know if it has anything to do with tablespaces or > what, but I'm really starting to get frustrated. > > I'm from a MySQL background and I'm completely stumped as to how > you can, through a script, insert data into a database *created at > the console* and not be able to select that data from the console. > I know it's there taking up space on my machine, and I can select > it from the script, but I can't manipulate it in any way outside of > that. > > Any thoughts? Something I just noticed is that when I run the script: #!/usr/bin/python # import pgdb module import pgdb # connect to the db db = pgdb.connect(host="localhost", database="test", user="postgres", password="*********") # instantiate cursor cursor = db.cursor() # insert 10 records for x in range(10): cursor.execute("INSERT INTO users (username, firstname, lastname, email, age) VALUES ('bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31)") # retrieve the data cursor.execute("SELECT * FROM users") result = cursor.fetchall() # print data to the screen for line in result: print line I end up seeing only ten records printed to the screen, when I should see 10, 20, 30, etc. every time I run the script. The serial column (userId) is incrementing but I'm not seeing any more that 10 results from the select query. - From the console: test=# select * from users; userid | username | firstname | lastname | email | age - --------+----------+-----------+----------+-------+----- (0 rows) Output from the script above: bfitzsimmons@epsilon:~/test$ ./postgresql_test.py [200313, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200314, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200315, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200316, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200317, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200318, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200319, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200320, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200321, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] [200322, 'bfitzsimmons', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFrdbRDpzwx2t8E5gRAhxAAJoC2NQ1JbAfV+DYavVUwUPpTo5+vgCglIcI UQNMBNEXH46qktyNwqt5AFY= =Bsok -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Alan Hodgson wrote: > On Tuesday 16 January 2007 22:42, Brant Fitzsimmons > <brant@bfcomputerconsulting.com> wrote: >> Records that are entered at the console show up when I do a >> select with the script, but not the other way around. I have >> tried to the RTFM as much as possible, but I'm still lost as to >> why while accessing the same table I can't access the data >> manipulated by the script. I don't know if it has anything to do >> with tablespaces or what, but I'm really starting to get >> frustrated. > > Is the script starting a transaction and not committing it? If so, > the changes it makes will not be visible to other processes. psql > by default operates in auto-commit mode, every statement is > committed on completion. No transactions; just simple inserts. > > If this is not the case, I would have to say you are not in fact > working on the same table, somehow. That's what i was thinking as well, but how is that possible? If I insert a record at the console the data shows up in a select made in the script. If I insert a record in the script I can not see that data in a select from the console. If I add a column at the console i am able to insert into that column in my script. After that insert I am able to retrieve the newly inserted data from the script, but not from the console. It doesn't make any sense to me. - -- Brant Fitzsimmons brant@bfcomputerconsulting.com - ------------------------------------------------------------------- "Strange times are these in which we live when the old and the young are taught falsehoods in the schools of learning. And the one man that dares to tell the truth is called at once a lunatic and a fool." -Plato -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFrdkODpzwx2t8E5gRArfTAJ4zPndrqfbIR+f7PhA2CnV4S1pjnwCdGgCf 9vCfTAVLaDEZ/C9b6reflhI= =A/vg -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jasbinder Singh Bali wrote: > Please attach a snippet of your python script and lets see what are > you doing there. That might make things easy. Jas Here is the entire test script: #!/usr/bin/python # import pgdb module import pgdb # connect to the db db = pgdb.connect(host="localhost", database="test", user="postgres", password="**********") # instantiate cursor cursor = db.cursor() # insert 10 records for x in range(10): cursor.execute("INSERT INTO users (username, firstname, lastname, email, age) VALUES ('brant', 'Brant', 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31)") # retrieve the data cursor.execute("SELECT * FROM users") result = cursor.fetchall() # print data to the screen for line in result: print line -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFrdkhDpzwx2t8E5gRAiPpAJ0QHGmawHqiZWy2NKTUbWncrpWWGgCdF3oS IjwEPfhuuvIthx4U8MsoyHA= =lvc7 -----END PGP SIGNATURE-----
On Wednesday 17 January 2007 03:06, Brant Fitzsimmons wrote: > Jasbinder Singh Bali wrote: > > Please attach a snippet of your python script and lets see what are > > you doing there. That might make things easy. Jas > > Here is the entire test script: > > #!/usr/bin/python > > # import pgdb module > import pgdb > > # connect to the db > db = pgdb.connect(host="localhost", database="test", user="postgres", > password="**********") > > # instantiate cursor > cursor = db.cursor() > > # insert 10 records > for x in range(10): > cursor.execute("INSERT INTO users (username, firstname, lastname, > email, age) VALUES ('brant', 'Brant', 'Fitzsimmons', > 'brant@bfcomputerconsulting.com', 31)") Put in a db.commit() statement here. Does that fix your problem? > # retrieve the data > cursor.execute("SELECT * FROM users") > result = cursor.fetchall() > > # print data to the screen > for line in result: > print line > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings
This is what your table creation script is like for table 'users' that doesn't have any field named 'age' >I created a table from the prompt using: create table users (userID >serial, userName varchar(32), firstName varchar(32), lastName >varchar(64), email varchar(128)); Now when you are inserting the values in this table using your python script, it says something like > cursor.execute("INSERT INTO users (username, firstname, lastname, >email, age) VALUES ('brant', 'Brant', 'Fitzsimmons', >'brant@bfcomputerconsulting.com', 31)") Field 'age' doesn't exist atall in table 'users' and hence the transaction would not commit. Thanks, ~Jas On 1/17/07, Brant Fitzsimmons <brant@bfcomputerconsulting.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Jasbinder Singh Bali wrote: > > Please attach a snippet of your python script and lets see what are > > you doing there. That might make things easy. Jas > > Here is the entire test script: > > #!/usr/bin/python > > # import pgdb module > import pgdb > > # connect to the db > db = pgdb.connect(host="localhost", database="test", user="postgres", > password="**********") > > # instantiate cursor > cursor = db.cursor() > > # insert 10 records > for x in range(10): > cursor.execute("INSERT INTO users (username, firstname, lastname, > email, age) VALUES ('brant', 'Brant', 'Fitzsimmons', > 'brant@bfcomputerconsulting.com', 31)") > > # retrieve the data > cursor.execute("SELECT * FROM users") > result = cursor.fetchall() > > # print data to the screen > for line in result: > print line > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.3 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFFrc/TDpzwx2t8E5gRAu2UAJ9/xlk6EaSPAWyE5XRp50qftb3xRQCeKwtS > HwNXoc2k91/hlxVHnexm05U= > =vm0M > -----END PGP SIGNATURE----- > >
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Sean Davis wrote:
> On Wednesday 17 January 2007 03:06, Brant Fitzsimmons wrote:
>> Jasbinder Singh Bali wrote:
>>> Please attach a snippet of your python script and lets see what
>>> are you doing there. That might make things easy. Jas
>> Here is the entire test script:
>>
>> #!/usr/bin/python
>>
>> # import pgdb module import pgdb
>>
>> # connect to the db db = pgdb.connect(host="localhost",
>> database="test", user="postgres", password="**********")
>>
>> # instantiate cursor cursor = db.cursor()
>>
>> # insert 10 records for x in range(10): cursor.execute("INSERT
>> INTO users (username, firstname, lastname, email, age) VALUES
>> ('brant', 'Brant', 'Fitzsimmons',
>> 'brant@bfcomputerconsulting.com', 31)")
>
> Put in a db.commit() statement here. Does that fix your problem?
It sure does. Any idea why it would drive up the serial column even
though nothing was committed?
- --
Brant Fitzsimmons
brant@bfcomputerconsulting.com
- -------------------------------------------------------------------
"Strange times are these in which we live when the old and the
young are taught falsehoods in the schools of learning. And the one
man that dares to tell the truth is called at once a lunatic and
a fool."
-Plato
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFrjidDpzwx2t8E5gRAqK5AJsFcboXs3HK8uAyURI+PdwQeeh6UACeOu4l
GOtN3HuN6vba4IzeCvFpWWc=
=BUCF
-----END PGP SIGNATURE-----
Hash: SHA1
Sean Davis wrote:
> On Wednesday 17 January 2007 03:06, Brant Fitzsimmons wrote:
>> Jasbinder Singh Bali wrote:
>>> Please attach a snippet of your python script and lets see what
>>> are you doing there. That might make things easy. Jas
>> Here is the entire test script:
>>
>> #!/usr/bin/python
>>
>> # import pgdb module import pgdb
>>
>> # connect to the db db = pgdb.connect(host="localhost",
>> database="test", user="postgres", password="**********")
>>
>> # instantiate cursor cursor = db.cursor()
>>
>> # insert 10 records for x in range(10): cursor.execute("INSERT
>> INTO users (username, firstname, lastname, email, age) VALUES
>> ('brant', 'Brant', 'Fitzsimmons',
>> 'brant@bfcomputerconsulting.com', 31)")
>
> Put in a db.commit() statement here. Does that fix your problem?
It sure does. Any idea why it would drive up the serial column even
though nothing was committed?
- --
Brant Fitzsimmons
brant@bfcomputerconsulting.com
- -------------------------------------------------------------------
"Strange times are these in which we live when the old and the
young are taught falsehoods in the schools of learning. And the one
man that dares to tell the truth is called at once a lunatic and
a fool."
-Plato
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFrjidDpzwx2t8E5gRAqK5AJsFcboXs3HK8uAyURI+PdwQeeh6UACeOu4l
GOtN3HuN6vba4IzeCvFpWWc=
=BUCF
-----END PGP SIGNATURE-----
On Wednesday 17 January 2007 09:54, Brant Fitzsimmons wrote: > Sean Davis wrote: > > On Wednesday 17 January 2007 03:06, Brant Fitzsimmons wrote: > >> Jasbinder Singh Bali wrote: > >>> Please attach a snippet of your python script and lets see what > >>> are you doing there. That might make things easy. Jas > >> > >> Here is the entire test script: > >> > >> #!/usr/bin/python > >> > >> # import pgdb module import pgdb > >> > >> # connect to the db db = pgdb.connect(host="localhost", > >> database="test", user="postgres", password="**********") > >> > >> # instantiate cursor cursor = db.cursor() > >> > >> # insert 10 records for x in range(10): cursor.execute("INSERT > >> INTO users (username, firstname, lastname, email, age) VALUES > >> ('brant', 'Brant', 'Fitzsimmons', > >> 'brant@bfcomputerconsulting.com', 31)") > > > > Put in a db.commit() statement here. Does that fix your problem? > > It sure does. Any idea why it would drive up the serial column even > though nothing was committed? Great to hear.... A serial column is a macro to make a sequence and then to fill the column with the default "next_val" from the sequence. The mere selection of next_val increases the sequence, which is necessary to ensure that all connections get a unique value when selecting from the same sequence. Sean
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Sean Davis wrote:
> On Wednesday 17 January 2007 09:54, Brant Fitzsimmons wrote:
>> Sean Davis wrote:
>>> On Wednesday 17 January 2007 03:06, Brant Fitzsimmons wrote:
>>>> Jasbinder Singh Bali wrote:
>>>>> Please attach a snippet of your python script and lets see
>>>>> what are you doing there. That might make things easy. Jas
>>>> Here is the entire test script:
>>>>
>>>> #!/usr/bin/python
>>>>
>>>> # import pgdb module import pgdb
>>>>
>>>> # connect to the db db = pgdb.connect(host="localhost",
>>>> database="test", user="postgres", password="**********")
>>>>
>>>> # instantiate cursor cursor = db.cursor()
>>>>
>>>> # insert 10 records for x in range(10):
>>>> cursor.execute("INSERT INTO users (username, firstname,
>>>> lastname, email, age) VALUES ('brant', 'Brant',
>>>> 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31)")
>>> Put in a db.commit() statement here. Does that fix your
>>> problem?
>> It sure does. Any idea why it would drive up the serial column
>> even though nothing was committed?
>
> Great to hear....
>
> A serial column is a macro to make a sequence and then to fill the
> column with the default "next_val" from the sequence. The mere
> selection of next_val increases the sequence, which is necessary to
> ensure that all connections get a unique value when selecting from
> the same sequence.
>
> Sean
I see.
Thanks for your help and thanks to everyone who contributed ideas.
The quick response was unexpected and very encouraging.
- --
Brant Fitzsimmons
brant@bfcomputerconsulting.com
- -------------------------------------------------------------------
"Strange times are these in which we live when the old and the
young are taught falsehoods in the schools of learning. And the one
man that dares to tell the truth is called at once a lunatic and
a fool."
-Plato
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFrjx3Dpzwx2t8E5gRAip+AJ9QXHE1ft+CcAn1lDvMeNY7r7xMqwCgknw5
9IhV0WJwhzg8m1Ss21cEbY0=
=te1Z
-----END PGP SIGNATURE-----
Hash: SHA1
Sean Davis wrote:
> On Wednesday 17 January 2007 09:54, Brant Fitzsimmons wrote:
>> Sean Davis wrote:
>>> On Wednesday 17 January 2007 03:06, Brant Fitzsimmons wrote:
>>>> Jasbinder Singh Bali wrote:
>>>>> Please attach a snippet of your python script and lets see
>>>>> what are you doing there. That might make things easy. Jas
>>>> Here is the entire test script:
>>>>
>>>> #!/usr/bin/python
>>>>
>>>> # import pgdb module import pgdb
>>>>
>>>> # connect to the db db = pgdb.connect(host="localhost",
>>>> database="test", user="postgres", password="**********")
>>>>
>>>> # instantiate cursor cursor = db.cursor()
>>>>
>>>> # insert 10 records for x in range(10):
>>>> cursor.execute("INSERT INTO users (username, firstname,
>>>> lastname, email, age) VALUES ('brant', 'Brant',
>>>> 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31)")
>>> Put in a db.commit() statement here. Does that fix your
>>> problem?
>> It sure does. Any idea why it would drive up the serial column
>> even though nothing was committed?
>
> Great to hear....
>
> A serial column is a macro to make a sequence and then to fill the
> column with the default "next_val" from the sequence. The mere
> selection of next_val increases the sequence, which is necessary to
> ensure that all connections get a unique value when selecting from
> the same sequence.
>
> Sean
I see.
Thanks for your help and thanks to everyone who contributed ideas.
The quick response was unexpected and very encouraging.
- --
Brant Fitzsimmons
brant@bfcomputerconsulting.com
- -------------------------------------------------------------------
"Strange times are these in which we live when the old and the
young are taught falsehoods in the schools of learning. And the one
man that dares to tell the truth is called at once a lunatic and
a fool."
-Plato
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFrjx3Dpzwx2t8E5gRAip+AJ9QXHE1ft+CcAn1lDvMeNY7r7xMqwCgknw5
9IhV0WJwhzg8m1Ss21cEbY0=
=te1Z
-----END PGP SIGNATURE-----
Please consider the archives when choosing a Subject line. On Wed, Jan 17, 2007 at 10:10:47AM -0500, Brant Fitzsimmons wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Sean Davis wrote: > > On Wednesday 17 January 2007 09:54, Brant Fitzsimmons wrote: > >> Sean Davis wrote: > >>> On Wednesday 17 January 2007 03:06, Brant Fitzsimmons wrote: > >>>> Jasbinder Singh Bali wrote: > >>>>> Please attach a snippet of your python script and lets see > >>>>> what are you doing there. That might make things easy. Jas > >>>> Here is the entire test script: > >>>> > >>>> #!/usr/bin/python > >>>> > >>>> # import pgdb module import pgdb > >>>> > >>>> # connect to the db db = pgdb.connect(host="localhost", > >>>> database="test", user="postgres", password="**********") > >>>> > >>>> # instantiate cursor cursor = db.cursor() > >>>> > >>>> # insert 10 records for x in range(10): > >>>> cursor.execute("INSERT INTO users (username, firstname, > >>>> lastname, email, age) VALUES ('brant', 'Brant', > >>>> 'Fitzsimmons', 'brant@bfcomputerconsulting.com', 31)") > >>> Put in a db.commit() statement here. Does that fix your > >>> problem? > >> It sure does. Any idea why it would drive up the serial column > >> even though nothing was committed? > > > > Great to hear.... > > > > A serial column is a macro to make a sequence and then to fill the > > column with the default "next_val" from the sequence. The mere > > selection of next_val increases the sequence, which is necessary to > > ensure that all connections get a unique value when selecting from > > the same sequence. > > > > Sean > > I see. > > Thanks for your help and thanks to everyone who contributed ideas. > The quick response was unexpected and very encouraging. > > - -- > Brant Fitzsimmons > brant@bfcomputerconsulting.com > - ------------------------------------------------------------------- > "Strange times are these in which we live when the old and the > young are taught falsehoods in the schools of learning. And the one > man that dares to tell the truth is called at once a lunatic and > a fool." > -Plato > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.3 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFFrjx3Dpzwx2t8E5gRAip+AJ9QXHE1ft+CcAn1lDvMeNY7r7xMqwCgknw5 > 9IhV0WJwhzg8m1Ss21cEbY0= > =te1Z > -----END PGP SIGNATURE----- > -- You have no chance to survive make your time.