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.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to