Re: I'm very confused.
От | Jasbinder Singh Bali |
---|---|
Тема | Re: I'm very confused. |
Дата | |
Msg-id | a47902760701170432u551f2300r1a93b4a43fa757fb@mail.gmail.com обсуждение исходный текст |
Ответ на | I'm very confused. (Brant Fitzsimmons <brant@bfcomputerconsulting.com>) |
Список | pgsql-novice |
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----- > >
В списке pgsql-novice по дате отправления: