fix: connect to a database
This commit is contained in:
parent
8c6a3400f6
commit
eddc6d997d
11
Database.py
11
Database.py
@ -20,6 +20,17 @@ class Database:
|
|||||||
password = password,
|
password = password,
|
||||||
)
|
)
|
||||||
self.cursor = self.mydb.cursor()
|
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):
|
def _create_table(self, name: str, content: dict):
|
||||||
command: str = f"CREATE TABLE {name} ("
|
command: str = f"CREATE TABLE {name} ("
|
||||||
|
Loading…
Reference in New Issue
Block a user