This commit is contained in:
parent
7655c068f4
commit
0768bb7782
27
database.py
27
database.py
|
@ -4,29 +4,34 @@ import mysql.connector
|
|||
|
||||
|
||||
# Create Database or Table
|
||||
def create(db_cursor, name, _type):
|
||||
query = f'CREATE {_type} {name}'
|
||||
def create(db_cursor, name, type_):
|
||||
query = f'CREATE {type_} {name}'
|
||||
try:
|
||||
db_cursor.execute(query)
|
||||
except mysql.connector.Error as err:
|
||||
print('Something went wrong', err)
|
||||
|
||||
|
||||
def add(db_cursor):
|
||||
# TODO Frage / Antwort hinzufügen
|
||||
def add(db_cursor, name, type_):
|
||||
# TODO
|
||||
return
|
||||
|
||||
|
||||
def read(db_cursor):
|
||||
# TODO Frage / Antwort auslesen
|
||||
def read(db_cursor, name, type_):
|
||||
# TODO
|
||||
return
|
||||
|
||||
|
||||
def update(db_cursor):
|
||||
# TODO Frage / Antwort Aktualisieren
|
||||
def update(db_cursor, name, type_):
|
||||
# TODO
|
||||
return
|
||||
|
||||
|
||||
def del_(db_cursor):
|
||||
# TODO Frage / Antwort löschen
|
||||
return
|
||||
def del_(db_cursor, name, type_):
|
||||
query = f'DROP if exists {type_} {name}'
|
||||
try:
|
||||
db_cursor.execute(query)
|
||||
except mysql.connector.Error as err:
|
||||
print('Something went wrong', err)
|
||||
|
||||
|
||||
|
|
|
@ -4,16 +4,13 @@ import config
|
|||
import main_menu
|
||||
|
||||
|
||||
# Auskommentieren falls Server offline
|
||||
|
||||
|
||||
# Datenbank Menü
|
||||
def menu():
|
||||
enable_menu = True
|
||||
selection = {0: 'Datenbanken anzeigen', 1: 'Datenbank erstellen', 2: 'Datenbank löschen', 3: 'Datenbank umbenennen',
|
||||
4: 'Datenbank auselesen',
|
||||
5: 'Tabelle erstellen', 6: 'Tabelle umbenennen', 7: 'Tabelle löschen', 8: 'Tabelle auselsen',
|
||||
9: 'In Tabelle einfügen', 10: 'Tabellen anzeigen', 11: 'Zurück zum Hauptmenü'}
|
||||
5: 'Tabelle erstellen', 6: 'Tabelle umbenennen', 7: 'Tabelle löschen', 8: 'Tabelle auslesen',
|
||||
9: 'In Tabelle einfügen', 10: 'Tabellen anzeigen', 11: 'Zurück zum Hauptmenü', 12 : 'Frage/Antwort hinzufügen'}
|
||||
|
||||
print('#Datenbank Menü# \n'
|
||||
'\nWas möchtest du tun?\n')
|
||||
|
@ -31,8 +28,10 @@ def menu():
|
|||
database_name = input('Wie soll die Datenbank heißen?')
|
||||
database.create(cursor, database_name, _type)
|
||||
case 2:
|
||||
# TODO Funktion
|
||||
print('Datenbank löschen') # Platzhalter für die Funktion
|
||||
_type = 'DATABASE'
|
||||
print('#Datenbank löschen#') # Platzhalter für die Funktion
|
||||
database_name = input('Welche Datenbank soll gelöscht werden?')
|
||||
database.del_(cursor, database_name, _type)
|
||||
case 3:
|
||||
# TODO Funktion
|
||||
return
|
||||
|
@ -61,5 +60,8 @@ def menu():
|
|||
return
|
||||
case 11:
|
||||
main_menu.main_menu()
|
||||
case 12:
|
||||
# TODO Funktion
|
||||
return
|
||||
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue
Block a user