Pruefungskatalog/database/database_connection.py

16 lines
478 B
Python
Raw Normal View History

2022-03-22 23:09:39 +01:00
import mysql.connector
# Aufbau der verbindung zum Mysql Server
def db_connection(user, password, host, database):
connection = ''
try:
# Verbindung - Eingaben in der config.py bestimmen
connection = mysql.connector.connect(user=user, password=password, host=host, database=database)
except mysql.connector.Error as err:
print('Something went wrong', err)
print('Veruche deinen Mysql Server neu zu starten')
return connection