Problem w/ MySQLdb
MRAB
python at mrabarnett.plus.com
Tue Feb 15 15:53:23 EST 2011
On 15/02/2011 20:24, Victor Subervi wrote:
> Hi;
> I have a function that calls the following class:
>
> #!/usr/bin/python
>
> import sys,os
> sys.path.append(os.getcwd())
> import MySQLdb
> from login import login
> import re, string
>
> def buildTableColorShortOptions():
> user, passwd, db, host = login()
> database = MySQLdb.connect(host, user, passwd, db)
> cursor = database.cursor()
> cursor.execute('''create table if not exists colorShortOptions (
> Color varchar(40) not null,
> Value bool not null default '0'
> ) engine=innodb''')
> cursor.execute("insert into colorShortOptions (Color) values ('indigo')")
> cursor.execute("insert into colorShortOptions (Color) values ('maroon')")
[snip]
> cursor.execute("insert into colorShortOptions (Color) values ('teal')")
> cursor.close()
>
> It builds the table but fails from the first insertion. Trying to insert
> using that code directly in MySQL does indeed work. Why?
>
You didn't commit the changes.
More information about the Python-list
mailing list