Answer the question
In order to leave comments, you need to log in
MySQL error. How to decide?
Gives an error message:
raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.
from getpass import getpass
from mysql.connector import connect, Error
try:
with connect(
host="localhost",
user="root",
password="Current-Root-Password",
database="valen_bot"
) as connection:
print(connection)
except Error as e:
print(e)
show_table_query = "valen_info"
with connection.cursor() as cursor:
cursor.execute(show_table_query)
# Fetch rows from last executed query
result = cursor.fetchall()
for row in result:
print(row)
Answer the question
In order to leave comments, you need to log in
Well, who knows - you don't give details. Maybe you don't have MySQL on localhost. It may be that Current-Root-Password is used as a password, but you do not notice. Or maybe access to the database is denied with a password from localhost (which is unlikely, but still). What is "valen_info" in general - where was this code copied from in general?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question