fix: connect to a database

This commit is contained in:
starnakin 2023-06-04 12:12:14 +02:00
parent 8c6a3400f6
commit eddc6d997d

View File

@ -20,6 +20,17 @@ class Database:
password = password,
)
self.cursor = self.mydb.cursor()
self.cursor.execute("SHOW DATABASES");
if (not "zeolak" in self.cursor):
self.cursor.execute("CREATE DATABASE zeolak")
self.mydb = mysql.connector.connect(
host = host,
port = port,
user = user,
password = password,
database = "zeolak"
)
self.cursor = self.mydb.cursor()
def _create_table(self, name: str, content: dict):
command: str = f"CREATE TABLE {name} ("