From cbcdfcf11eb9d7a88611a6cb4890025af94d3c94 Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 18 Mar 2022 12:55:29 +0100 Subject: [PATCH] #6 Added Auto-installer for requirements --- database.py | 1 + database_connection.py | 1 + main.py | 3 ++- requirements_installer.py | 8 ++++++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 requirements_installer.py diff --git a/database.py b/database.py index 3d9e9b3..7e16e8b 100644 --- a/database.py +++ b/database.py @@ -1,4 +1,5 @@ # TODO: Datenbank Klasse (CRUD) + import mysql.connector diff --git a/database_connection.py b/database_connection.py index aee5fb8..263a96a 100644 --- a/database_connection.py +++ b/database_connection.py @@ -12,4 +12,5 @@ def db_connection(user, password, host): connection = mysql.connector.connect(user=user, password=password, host=host) except mysql.connector.Error as err: print('Something went wrong', err) + print('Veruche deinen Mysql Server neuzustarten') return connection.cursor() diff --git a/main.py b/main.py index c0cbce8..50e4c08 100644 --- a/main.py +++ b/main.py @@ -4,10 +4,11 @@ # Datenbanken (CRUD) Tabellen (CRUD) import main_menu - +import requirements_installer # Aufruf des Main MenĂ¼se def main(): + # requirements_installer.installer() main_menu.main_menu() diff --git a/requirements_installer.py b/requirements_installer.py new file mode 100644 index 0000000..107db3f --- /dev/null +++ b/requirements_installer.py @@ -0,0 +1,8 @@ +import sys +import subprocess + + +# implement pip as a subprocess: +def installer(): + subprocess.check_call([sys.executable, '-m', 'pip', 'install', + 'mysql-connector-python']) \ No newline at end of file