MySQLdb trouble

Nicolay A. Vasiliev nvasiliev at whiteriversoft.com
Wed May 10 04:23:30 EDT 2006


Hello there!

I got some trouble trying to insert data into the database with MySQLdb 
module.

I have such code:

from MySQLdb import *

def loc_connect_db():
    """
    The DB connection subroutine
    """
    db = MySQLdb.connect(host = "localhost",
                        user = "root",
                        passwd="mysql",
                        db="some_db")
    return db

db = loc_connect_db()
cursor = db.cursor()

query = """insert ignore into categories (cat_id, cat_name, parent) 
values (%d, "%s", %d)""" % (int(CatId), CatName.capitalize(), int(parent))
print query
cursor.execute(query)

Queries are formed in the loop, they look fine. No errors, but no 
effect, records are not inserted into the table. There is my possible 
mistake?

Any suggestions are very appreciated - Thanks in advance.

Best regards,
Nicolay



More information about the Python-list mailing list