2022-03-18 12:30:09 +01:00
|
|
|
import database
|
|
|
|
import database_connection
|
|
|
|
import config
|
2022-03-18 13:07:12 +01:00
|
|
|
import main_menu
|
|
|
|
|
2022-03-18 12:30:09 +01:00
|
|
|
|
|
|
|
# Datenbank Menü
|
|
|
|
def menu():
|
2022-03-19 20:55:12 +01:00
|
|
|
connection = database_connection.db_connection(config.user, config.password, config.host, None)
|
2022-03-18 22:07:50 +01:00
|
|
|
|
2022-03-19 20:55:12 +01:00
|
|
|
selection = {0: ' Datenbanken anzeigen', 1: ' Datenbank erstellen', 2: ' Datenbank löschen', 3: ' Datenbank umbenennen',
|
|
|
|
4: ' Datenbanken benutzen',
|
|
|
|
5: ' Tabelle erstellen', 6: ' Tabelle umbenennen', 7: ' Tabelle löschen', 8: ' Tabelle auslesen',
|
|
|
|
9: ' In Tabelle einfügen', 10: 'Tabellen anzeigen', 11: 'Frage/Antwort hinzufügen', 12: 'Zurück zum Hauptmenü'}
|
2022-03-18 12:30:09 +01:00
|
|
|
|
|
|
|
print('#Datenbank Menü# \n'
|
|
|
|
'\nWas möchtest du tun?\n')
|
|
|
|
|
2022-03-18 22:07:50 +01:00
|
|
|
while True:
|
2022-03-19 20:55:12 +01:00
|
|
|
|
2022-03-18 22:07:50 +01:00
|
|
|
cursor = connection.cursor()
|
2022-03-18 12:30:09 +01:00
|
|
|
for key, value in selection.items():
|
|
|
|
print(key, value)
|
2022-03-18 22:07:50 +01:00
|
|
|
selection_number = int(input('\nBitte Auswahl treffen\n'))
|
2022-03-18 12:30:09 +01:00
|
|
|
|
|
|
|
match selection_number:
|
2022-03-18 22:07:50 +01:00
|
|
|
case 0:
|
|
|
|
use_type = 'DATABASES'
|
2022-03-22 13:10:45 +01:00
|
|
|
print('# Datenbanken #\n')
|
2022-03-18 22:07:50 +01:00
|
|
|
database.show(cursor, use_type)
|
2022-03-18 12:30:09 +01:00
|
|
|
case 1:
|
2022-03-18 22:07:50 +01:00
|
|
|
use_type = 'DATABASE'
|
|
|
|
print('# Datenbank erstellen #\n')
|
|
|
|
database_name = input('Wie soll die Datenbank heißen?\n')
|
|
|
|
database.create(cursor, database_name, use_type)
|
2022-03-18 12:30:09 +01:00
|
|
|
case 2:
|
2022-03-18 22:07:50 +01:00
|
|
|
use_type = 'DATABASE'
|
|
|
|
print('# Datenbank löschen #\n') # Platzhalter für die Funktion
|
|
|
|
database_name = input('Welche Datenbank soll gelöscht werden?\n')
|
|
|
|
database.del_(cursor, database_name, use_type)
|
2022-03-18 12:30:09 +01:00
|
|
|
case 3:
|
2022-03-22 13:10:45 +01:00
|
|
|
print('--Funktion ist in Arbeit-- \n')
|
|
|
|
continue
|
2022-03-18 12:30:09 +01:00
|
|
|
case 4:
|
2022-03-19 20:55:12 +01:00
|
|
|
name = input('Welche Datenbank möchtest du benutzen?\n')
|
|
|
|
database.use(cursor, name)
|
|
|
|
connection.database = name
|
2022-03-18 12:30:09 +01:00
|
|
|
case 5:
|
2022-03-18 22:07:50 +01:00
|
|
|
use_type = 'TABLE'
|
|
|
|
print('# Tabelle erstellen #\n')
|
|
|
|
table_name = input('Wie soll die Datenbank heißen?\n')
|
|
|
|
database.create(cursor, table_name, use_type)
|
2022-03-18 13:07:12 +01:00
|
|
|
case 6:
|
2022-03-22 13:10:45 +01:00
|
|
|
print('--Funktion ist in Arbeit-- \n')
|
|
|
|
continue
|
2022-03-18 13:07:12 +01:00
|
|
|
case 7:
|
2022-03-22 13:10:45 +01:00
|
|
|
print('--Funktion ist in Arbeit-- \n')
|
|
|
|
continue
|
2022-03-18 13:07:12 +01:00
|
|
|
case 8:
|
2022-03-19 20:55:12 +01:00
|
|
|
print('# Tabelle Auslesen #\n')
|
|
|
|
name = input('Aus welcher Tabelle soll dir alles angezeigt werden?\n')
|
|
|
|
database.read(cursor, name)
|
|
|
|
|
2022-03-18 13:07:12 +01:00
|
|
|
case 9:
|
2022-03-22 13:10:45 +01:00
|
|
|
print('--Funktion ist in Arbeit-- \n')
|
|
|
|
continue
|
2022-03-18 13:07:12 +01:00
|
|
|
case 10:
|
2022-03-19 20:55:12 +01:00
|
|
|
database.show_tables(cursor)
|
|
|
|
print(str(cursor.fetchall()).replace(',', ''))
|
2022-03-18 13:07:12 +01:00
|
|
|
return
|
|
|
|
case 11:
|
2022-03-18 22:07:50 +01:00
|
|
|
table_name = str(input('Bitte den Tabellennamen angeben\n'))
|
|
|
|
print("#Fragen und Antworten hinzufügen #\n")
|
|
|
|
question = str(input('Bitte die Frage eingeben\n'))
|
|
|
|
answer = str(input('Bitte die dazugehörige antwort eingeben\n'))
|
|
|
|
database.add(cursor, table_name, question, answer)
|
2022-03-18 15:06:02 +01:00
|
|
|
case 12:
|
2022-03-18 22:07:50 +01:00
|
|
|
main_menu.main_menu()
|
|
|
|
|
2022-03-18 12:30:09 +01:00
|
|
|
|