AttributeError: ‘tuple’ object has no attribute ‘encode’ MYsql

So this is the piece of code that is giving me the error

mycursor.execute("CREATE TABLE IF NOT EXISTS", str(share_name), "(nickname VARCHAR(255), date VARCHAR(255), bill VARCHAR(255), quantity VARCHAR(255), rate VARCHAR(255), amount(255))")
insert = f"INSERT INTO", str(share_name), "(nickname) VALUES (%s)"
val = str(share_nick)
mycursor.execute(insert, val)

p and this is the error

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "C:\Users\Shourya Kumar.DESKTOP-M2TQLD2\Desktop\papa project\addshare.py", line 36, in submit
    mycursor.execute(insert, val)
  File "C:\Users\Shourya Kumar.DESKTOP-M2TQLD2\Desktop\papa project\venv\lib\site-packages\mysql\connector\cursor.py", line 545, in execute
    stmt = operation.encode(self._connection.python_charset)
AttributeError: 'tuple' object has no attribute 'encode'

line 36 is this one mycursor.execute(insert, val)

I have just given the code that is actually fiving the error, if you guys need the rest of the code, tell me Ill upload a link



Read more here: https://stackoverflow.com/questions/67932760/attributeerror-tuple-object-has-no-attribute-encode-mysql

Content Attribution

This content was originally published by Tubes Myth at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: