title: AttributeError: 'tuple' object has no attribute 'encode' - MySQL.connector.Python
body: <p>Alrighty
  So this is the error</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:/Users/Mandem/PycharmProjects/untitled/Pranks/Lib/site-packages/Ada.py&quot;, line 161, in &lt;module&gt;
      mycursor.execute(updaterScoren)
    File &quot;C:\Users\Mandem\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\cursor.py&quot;, line 546, in execute
      stmt = operation.encode(self._connection.python_charset)
  AttributeError: 'tuple' object has no attribute 'encode'
  
  Process finished with exit code 1
  </code></pre>
  <p>This is the command I am trying to run</p>
  <pre><code>        f = int(input(
              &quot;Kodeord - bemærk her, at kodeordene er pinkoderne fra min egen database, bare indtast en værdi mellem 1-6&quot;))
          mycursor.execute(&quot;SELECT id,adresse,name,pinkode_brugt,score FROM bois WHERE id=%s&quot;, (f,))
  
          # MySQL Commands
          updaterScoren = &quot;UPDATE bois SET pinkode_brugt = pinkode_brugt + 1 WHERE id = %s&quot;, (f,)
  </code></pre>
  <p>I am running it like this:</p>
  <pre><code># MySQL Commands
          updaterScoren = &quot;UPDATE bois SET pinkode_brugt = pinkode_brugt + 1 WHERE id = %s&quot;, (f,)
  
          myresult = mycursor.fetchall()
  
          row_count = mycursor.rowcount
          print(myresult)
          print(&quot;number of affected rows: {}&quot;.format(row_count))
          if row_count == 1:
  
              print(row_count)
              print(app.timerValue)
              while (i != app.timerValue) and (i &lt;= app.timerValue) and (doorButton != 1) and (app.stopButton != 1):
                  print('%.2f' % i)
                  i = i + 0.01
                  timeLeft = app.timerValue - i
                  iTwo = app.timerValue
                  print(&quot;THIS IS X&quot;, app.timerValue)
                  time.sleep(0.01)
              # Hvis spillet stoppes, or i ikke når timerens slutværdi, vil scoren gemmes
              if (i != app.timerValue):
                  score = i
                  print(&quot;Dette er dit resultat: {}&quot;.format('%.2f' %score))
                  mycursor.execute(updaterScoren)
  </code></pre>
  <p>Sidenote, is it possible to also use &quot;myresult&quot; somehow to identify which row to change/update? So that, something ala &quot;UPDATE pinkode_brugt WHERE row = Myresult&quot;</p>
  <p>Here is  my full code:</p>
  <pre><code>import threading
  import tkinter as tk
  import pip
  import time
  import mysql.connector
  from time import sleep
  
  
  
  
  # NY THREAD(s), der kan vise scoreboarden på en skærm.
  class Timer(threading.Thread):
      def _init_(self):
          threading.Thread._init_(self)
          self.label = 0
          global score
  
  
      def run(self) -&gt; None:
          self.master = tk.Tk()
  
          self.master.gemoetry(&quot;+0+0&quot;)
  
          self.master = tk.Label(self.root, bg = &quot;black&quot;, fg = &quot;red&quot;)
  
          self.timer.grid(row = 1, column = 2)
  
          self.master.mainloop()
  
  
  class Tkinter(threading.Thread):
      def __init__(self):
          threading.Thread.__init__(self)
          self.daemon = True
          self.root = 0
          self.entry = 0
          self.label = 0
          self.button = 0
          self.timerValue = 0
          self.stopButton = 0
  
          self.start()
  
      def run(self) -&gt; 0:
          self.root = tk.Tk()
  
          # tkinter code goes here
          self.root.geometry(&quot;+2+0&quot;)
          self.root.config(background=&quot;black&quot;)
  
          self.label = tk.Label(self.root, bg=&quot;white&quot;, fg=&quot;black&quot;, font=(&quot;Fixedsys&quot;, 28))
          self.entry = tk.Entry(self.root, bg=&quot;white&quot;, fg=&quot;black&quot;, font=(&quot;Fixedsys&quot;, 28))
          self.stopTiden = tk.Button(self.root, bg=&quot;red&quot;, fg=&quot;white&quot;, text=&quot;Stop Spillet&quot;, command=self.stopTid)
          self.startTiden = tk.Button(self.root, bg=&quot;green&quot;, fg=&quot;white&quot;, text=&quot;Start Spillet&quot;, command=self.startTid)
  
          self.timerDisplay = tk.Label(self.root, bg=&quot;black&quot;, fg=&quot;red&quot;, text=&quot;Ceci n'est pas une timer&quot;)
  
          self.timerDisplay.grid(row=2, column=50)
          self.startTiden.grid(row=0, column=1)
          self.stopTiden.grid(row=0, column=10)
          self.entry.grid(row=1, column=1)
          self.label.grid(row=1, column=10)
  
          self.root.bind(&quot;&lt;KeyPress&gt;&quot;, self.read)
          self.root.mainloop()
  
      def displayTime(self):
          self.timerDisplay.config(text=i)
  
      def read(self, event):
          key = event.keysym
          try:
              if key == &quot;Return&quot;:
                  self.getA()
                  self.visTid()
          except:
              self.fejlTidvalg()
  
      def startTid(self):
          self.stopButton = 0
  
      def getA(self):
          self.timerValue = float(self.entry.get().format(&quot;%.2f&quot;, 1.23456))
          print(self.timerValue)
          return self.timerValue
  
      def stopTid(self):
          self.stopButton = 1
  
      def visTid(self):
          self.label.config(text=&quot;Det her er timerens slutværdi: {}&quot;.format(self.timerValue))
  
      def fejlTidvalg(self):
          self.label.config(text=&quot;FEJL -Vælg Venligst Et Tal&quot;)
  
  
  app = Tkinter()
  
  stopTiden = 0
  
  # Login til databasen
  mydb = mysql.connector.connect(
      host=&quot;****&quot;,
      user=&quot;****&quot;,
      password=&quot;*****&quot;,
      database='mydatabase',
      auth_plugin='mysql_native_password'
  )
  
  doorButton = 0
  
  while (doorButton != 1):
      stopButton = app.stopButton
      timerValue = app.timerValue
      iTwo = timerValue
      doorButton = 0
      i = 0.00
      mycursor = mydb.cursor()
  
  
      def countdown(i):
  
          while i:
              mins, secs = divmod(t, 60)
              timer = '{:02d}:{:02d}'.format(mins, secs)
              print(timer, end=&quot;\r&quot;)
              time.sleep(1)
              t -= 1
  
  
      # Servodøren skal åbnes her i denne kode
      while (app.stopButton != 1):
          # Indtast Pinkoden
          f = int(input(
              &quot;Kodeord - bemærk her, at kodeordene er pinkoderne fra min egen database, bare indtast en værdi mellem 1-6&quot;))
          mycursor.execute(&quot;SELECT id,adresse,name,pinkode_brugt,score FROM bois WHERE id=%s&quot;, (f,))
  
          # MySQL Commands
          updaterScoren = &quot;UPDATE bois SET pinkode_brugt = pinkode_brugt + 1 WHERE id = %s&quot;, (f,)
  
          myresult = mycursor.fetchall()
  
          row_count = mycursor.rowcount
          print(myresult)
          print(&quot;number of affected rows: {}&quot;.format(row_count))
          if row_count == 1:
  
              print(row_count)
              print(app.timerValue)
              while (i != app.timerValue) and (i &lt;= app.timerValue) and (doorButton != 1) and (app.stopButton != 1):
                  print('%.2f' % i)
                  i = i + 0.01
                  timeLeft = app.timerValue - i
                  iTwo = app.timerValue
                  print(&quot;THIS IS X&quot;, app.timerValue)
                  time.sleep(0.01)
              # Hvis spillet stoppes, or i ikke når timerens slutværdi, vil scoren gemmes
              if (i != app.timerValue):
                  score = i
                  print(&quot;Dette er dit resultat: {}&quot;.format('%.2f' %score))
                  mycursor.execute(updaterScoren)
  
  
              else:
                  print(&quot;Ingen point&quot;)
                  mycursor.execute()
  
  
          i = 0
      # Her skal du tilføje i til den ID's row, der lige har åbnet via sin pinkode. Så er du stort set færdig! :D
  </code></pre>
  <p>Ps. I have looked at the other posts regarding the same issue. As far as I understood it, their solutions didn't help.</p>