I have a DB and when I query a table I get 67 results. The SQL is:
SELECT lower(UserName) from Participants ;
I try to connect to the DB, and I get no connection errors.
def db_connect (): try: cnx = mysql.connector.connect(user=db_user, password=db_password,host=db_host,database=db_name) return cnx except mysql.connector.Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: print("Something is wrong with your user name or password") elif err.errno == errorcode.ER_BAD_DB_ERROR: print("Database does not exist") else: print(err) def main(): cnx = db_connect() cursor = cnx.cursor() query = ("SELECT lower(UserName) from Participants ;") cursor.execute(query) print(cursor.rowcount)
It prints out -1 for rowcount. The connection to the DB appears to be working, the SQL is a simple query…
- Try adding