Code
For a cursor-query:
import mysql.connector
from mysql.connector import errorcode
config = {
'user': 'root',
'password': 'root',
'host': 'localhost',
'database': 'myDatabase'}
cn = mysql.connector.connect(**config)
cur = cn.cursor()
emailExist = cur.execute("""SELECT * FROM customerDetails""").fetchall()
print(emailExist)
My database file is in the same directory as this script.
AttributeError
I get this error:
>>> emailExist = cur.execute("""SELECT * FROM customerDetails""").fetchall()
>>> AttributeError: 'NoneType' object has no attribute 'fetchall'
Expected
When I run the same query in MySQLWorkbench the output is:
0 row(s) returned
executedoesn’t return anything. Callfetchallon the cursor object itself!