This commit is contained in:
parent
fa472b5264
commit
ef7d93b244
12
database.py
12
database.py
|
@ -1,6 +1,5 @@
|
||||||
# TODO: Datenbank Klasse (CRUD)
|
# TODO: Datenbank Klasse (CRUD)
|
||||||
|
import mysqlx
|
||||||
import database_connection
|
|
||||||
|
|
||||||
|
|
||||||
def create_database(db_cursor):
|
def create_database(db_cursor):
|
||||||
|
@ -8,9 +7,12 @@ def create_database(db_cursor):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def create_table(db_cursor):
|
def create_table(db_cursor, database_name):
|
||||||
# TODO Table erstellen
|
query = f'CREATE DATABASE {database_name}'
|
||||||
return
|
try:
|
||||||
|
db_cursor.execute(query)
|
||||||
|
except mysqlx.Error as err:
|
||||||
|
print('Something went wrong', err)
|
||||||
|
|
||||||
|
|
||||||
def add(db_cursor):
|
def add(db_cursor):
|
||||||
|
|
3
main.py
3
main.py
|
@ -23,7 +23,8 @@ def menu():
|
||||||
|
|
||||||
match selection_number:
|
match selection_number:
|
||||||
case 1:
|
case 1:
|
||||||
print('Datenbank erstellen') # Platzhalter für die Funktion
|
print('#Datenbank erstellen#') # Platzhalter für die Funktion
|
||||||
|
database_name = input('Wie soll die Datenbank heißen?')
|
||||||
database.create_database(cursor)
|
database.create_database(cursor)
|
||||||
case 2:
|
case 2:
|
||||||
print('Datenbank löschen') # Platzhalter für die Funktion
|
print('Datenbank löschen') # Platzhalter für die Funktion
|
||||||
|
|
Loading…
Reference in New Issue
Block a user