Выдает ошибку:
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)