title: Get items from a database tuple in Python
body: <p>This is my code:</p>
  
  <pre><code>import pymysql
  
  def connect():
      print("connect to database")
      pw = input("Password: ")
      conn = pymysql.connect(host='localhost', port=3306, 
                             user='root', passwd=pw, db='contacts')
      conn.autocommit(True)
      cur_ = conn.cursor()
      return cur_
  
  def show_tables(self):
      print("show tables: ")
      self.execute("""SHOW TABLES""")
      print(self.fetchall())
      return self.fetchall()
  
  db = connect()
  table_names = show_tables(db)  # returns a tuple
  print(len(table_names))  # output zero
  table_name = table_names[0][0]  # ? - todo - get item from tuple
  </code></pre>
  
  <p><code>show_tables()</code> return the value <code>(('person',),)</code>.
  I want to get the name <code>person</code> with <code>table_names[0][0]</code>. But this doesn't work. Also the length of <code>(('person',),)</code> is 0. But why?</p>
  
  <p>Edit:
  I get the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/kame/Dropbox/code/python/scripts/database.py", line 65, in &lt;module&gt;
      table_name = table_names[0][0]  # ? - todo - get item from tuple
  IndexError: tuple index out of range
  </code></pre>