MySql

miker2 at optusnet.com.au miker2 at optusnet.com.au
Thu Jul 27 03:22:14 EDT 2006


Marc 'BlackJack' Rintsch wrote:
> In <1153982385.121336.41500 at i3g2000cwc.googlegroups.com>, miker2 wrote:
>
> > import MySQLdb
> > base = MySQLdb.connect(host="localhost", user="blah", passwd="blah",
> > db="test_py")
> > cursor = base.cursor()
> > cursor.execute("INSERT INTO table (field) VALUES (int)")
> >
> > this does not work but the interesting thing is, there is an
> > AUTO_INCREMENT
> > field. Now say i had a couple of entries in there already:
> >                                    auto  table
> >                                     1    |    90
> >                                     2    |    32
> >
> > and then i run my py script 3 times, the data is not entered but if i
> > add
> > another entry from mysql the auto increment field will have counted the
> >
> > python entries:
> >                        auto    table
> >                          1    |    90
> >                          2    |    32
> >                          6    |    47
> >
> > please tell me what i am doing wrong. thanks.
>
> Where's the problem?  Do you mind that the third entry has a 6 as unique
> `auto` value?  Doesn't `AUTO_INCREMENT` just guarantee unique values?
>
> Ciao,
> 	Marc 'BlackJack' Rintsch

the problem is that the entry from python: cursor.execute("INSERT INTO
table (field) VALUES (3)") is not there.

the auto increment counts the entries 1,2,3,4,5, ect.   the 3,4,5 in
the example above is where i've run the py script and as you can see
there are not there.  the 6 is an entry from mysql.

so basically the data from python is not being entered but the auto
increment is being counted. thanks.

sorry about the dodgie description.




More information about the Python-list mailing list