Pruefungskatalog/database_connection.py

20 lines
482 B
Python
Raw Normal View History

2022-03-18 22:07:50 +01:00
2022-03-17 13:22:44 +01:00
import mysql.connector
2022-03-17 13:36:16 +01:00
2022-03-18 12:30:09 +01:00
# Aufbau der verbindung zum Mysql Server
2022-03-18 22:07:50 +01:00
2022-03-19 20:55:12 +01:00
def db_connection(user, password, host, database):
2022-03-17 13:36:16 +01:00
connection = ''
2022-03-17 13:22:44 +01:00
try:
2022-03-19 20:55:12 +01:00
# Verbindung - Eingaben in der config.py bestimmen
connection = mysql.connector.connect(user=user, password=password, host=host, database=database)
2022-03-17 13:22:44 +01:00
except mysql.connector.Error as err:
2022-03-17 13:36:16 +01:00
print('Something went wrong', err)
2022-03-18 13:07:12 +01:00
print('Veruche deinen Mysql Server neu zu starten')
2022-03-18 22:07:50 +01:00
return connection