[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: MySql
From: ftc <ftc () chez ! com>
Date: 2006-07-27 10:43:24
Message-ID: 44c8983b$0$25158$636a55ce () news ! free ! fr
[Download RAW message or body]
miker2@optusnet.com.au a écrit :
> 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.
The dbapi2 specification says:
"if the database supports an auto-commit feature, this must be initially
off"
So you have to do a commit ( base.commit() ) or to enable auto-commit at
the beginning ( base.autocommit( True ) )
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic