Skip navigation links

MySQL Forums :: Connector/Python :: mysqldb interfaceError


Advanced Search

Re: mysqldb interfaceError
Posted by: Geert Vanderkelen ()
Date: April 19, 2011 05:34AM

Hi!

First, you open a connection using MySQLdb.connect():

def __init__(self):
..
self.conn = MySQLdb.connect(host=..)

Then, you have to change the following execute-method too:

def execute(self, query):
cur = self.conn.cursor()
cur.execute(query)
self.conn.commit()
cur.close()


Even better is to get rid of this newFormat-function and do this:

def execute(self, query, data):
cur = self.conn.cursor()
cur.execute(query, data)
self.conn.commit()
cur.close()


Use the execute()-method like follows:

db.execute("INSERT INTO Format (form_name, form_width, form_height, form_fps) VALUES (%s,%s,%s,%s)", ('HD',0,0,0))

Cheers,
Geert

(sorry for the crappy forum code displaying..)

Geert Vanderkelen
Software Developer at Oracle

Options: ReplyQuote


Subject Written By Posted
mysqldb interfaceError johanna royer 04/19/2011 03:37AM
Re: mysqldb interfaceError Geert Vanderkelen 04/19/2011 05:34AM
Re: mysqldb interfaceError johanna royer 04/19/2011 06:13AM
Re: mysqldb interfaceError johanna royer 04/20/2011 03:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.