Why would mysql execute return None?

I am trying to query a local MySQL database using Python’s (3.4) MySQL module with the following code:

class databases():

  def externaldatabase(self):

  try:
    c = mysql.connector.connect(host="127.0.0.1", user="user",
                                password="password", database="database")
     if c.is_connected():
           c.autocommit = True
      return(c)
    except:
         return(None)
    d = databases().externaldatabase()
    c = d.cursor() 
    r = c.execute('''select * from tbl_wiki''')
    print(r) 
> Returns: None

As far as I can tell, the connection is successfull, the database is composed of several rows but the query always returns the none type.

What instances does the MySQL execute function return None?


Source: sql

Leave a Reply