From eddc6d997db844baa0fa0e0e6266b215f734fdd2 Mon Sep 17 00:00:00 2001 From: starnakin Date: Sun, 4 Jun 2023 12:12:14 +0200 Subject: [PATCH] fix: connect to a database --- Database.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Database.py b/Database.py index 1d07d49..f3b64a6 100644 --- a/Database.py +++ b/Database.py @@ -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} ("