-4
I was trying to add python integer values to a mysql database with the following code:
import MySQLdb
valor1 = input("Digite o primeiro valor: ")
valor2 = input("Digite o segundo valor: ")
conexaoMySQL = MySQLdb.connect(host="localhost",user="User",db="Database",passwd="password")
cursor = conexaoMySQL.cursor()
conexaoMySQL.select_db('password')
cursor.execute('INSERT INTO Dados (Campo1,Campo2) VALUES(?, ?)',
(valor1,valor2))
conexaoMySQL.commit()
conexaoMySQL.close()
But I’m getting this mistake:
line 204, in execute query = query % args
Typeerror: not all Arguments converted During bytes formatting
During Handling of the above Exception, Another Exception occurred:
Traceback (Most recent call last): File "/home/hymb/Pycharmprojects/Pythondevid01/Appclientpy/pro.py", line 8, in cursor.execute('INSERT INTO Data(Field1,Field2) VALUES(?, ?)',(value1,value2)) File "/home/hymb/Virtualdevlopmentpython/lib/python3.6/site-Packages/Mysqldb/Cursors.py", line 206, in execute raise Programmingerror(str(m)) Mysqldb. _exceptions.Programmingerror: not all Arguments converted During bytes formatting
In Mysql I have a database and a table with two fields that receive integers
You own 5
?
in consultation and passes 6 values...– Woss
Now that you’ve seen it, thank you
– Hytalo Bassi
If you change this in the question will not stop giving this error? Your question will no longer make sense...
– Woss
It’s not working yet, I already changed the values in my original code
– Hytalo Bassi
And exactly the same error occurs? Then it will be better to elaborate a [mcve] for the question
– Woss
Okay, I’ll try to do
– Hytalo Bassi