Skip to content
Advertisement

Why would MySQL execute return None?

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

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

What instances does the MySQL execute function return None?

Advertisement

Answer

Query executions have no return values.

The pattern you need to follow is:

Or in python:

Also some db modules allow you to iterate over the cursor using the for…in pattern, but triple-check that regarding mysql.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement