I am trying to work out what is wrong with my code. I am trying to enter data into a mysql, and python doesn't seem to like how i have done something.
Test Data
Name = "TestRegion"
Perent= "perent"
x1 = -100.0
x2 = -150.0
z1 = 94.0
z2 = 200.0
Code
def NewRegion(Name, Perent, x1, x2, z1, z2):
try:
con = SQLConnect()
cur = con.cursor()
sql = """INSERT INTO RegionName (Name, Perent, X1, X2, Z1, Z2) VALUES (?,?,?,?,?,?)"""
cur.execute(sql, (Name, Perent, x1, x2, z1, z2))
con.commit()
except mdb.Error, e:
con.rollback()
print "Error %d: %s" % (e.args[0],e.args[1])
finally:
if con:
con.close()
my issue I am guessing is how I am trying to pass the values to the sql statment.
my Error message is
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py, line 159, in execute
query = query % db.literal(args)
TypeError: not all arguments converted during string formatting