Can someone help and give me a tip here? I'm using Python 2.7 and MySQL-connector 1.0.12.
The following job_insert, with %f, raises the error "mysql.connector.errors.ProgrammingError: Wrong number of arguments during string formatting".
job = {'customer': u'Acme', 'period': 3.0, 'cost': 987654.543210123}
job_insert = "INSERT INTO f.job (customer, period, cost) VALUES (%(customer)s, %(period)f, %(cost)f);"
cursor.execute(job_insert, job)
When I use %s instead, mysql.connector inserts the values. However, the floats are trimmed by several decimal places, e.g. 3.0 to 3 and 987654.543210123 to 987654.5. Both database columns are float.
job_insert = "INSERT INTO f.job (customer, period, cost) VALUES (%(customer)s, %(period)s, %(cost)s);"
Thanks for your time.