diff --git a/.gitignore b/.gitignore index 93ec730..3e57f88 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -conf.ini \ No newline at end of file +config/conf.ini diff --git a/manage_sql/conf.ini.sample b/config/conf.ini.sample similarity index 100% rename from manage_sql/conf.ini.sample rename to config/conf.ini.sample diff --git a/manage_sql/__init__.py b/manage_sql/__init__.py index 629eb80..071782c 100755 --- a/manage_sql/__init__.py +++ b/manage_sql/__init__.py @@ -21,5 +21,5 @@ __license__ = 'Beerware' try: import pymysql except ImportError: - print('PyMSQL library not found') + print('PyMYSQL library not found') sys.exit(1) diff --git a/manage_sql/__pycache__/__init__.cpython-36.pyc b/manage_sql/__pycache__/__init__.cpython-36.pyc index 21d5920..a7b163a 100644 Binary files a/manage_sql/__pycache__/__init__.cpython-36.pyc and b/manage_sql/__pycache__/__init__.cpython-36.pyc differ diff --git a/manage_sql/__pycache__/manage_sql.cpython-36.pyc b/manage_sql/__pycache__/manage_sql.cpython-36.pyc index 9eebd31..4567192 100644 Binary files a/manage_sql/__pycache__/manage_sql.cpython-36.pyc and b/manage_sql/__pycache__/manage_sql.cpython-36.pyc differ diff --git a/manage_sql/conf.ini b/manage_sql/conf.ini deleted file mode 100644 index 4651b6d..0000000 --- a/manage_sql/conf.ini +++ /dev/null @@ -1,5 +0,0 @@ -[sql] -host=localhost -database=adherents_services -user=root -passwd=Boris1989! \ No newline at end of file diff --git a/manage_sql/manage_sql.py b/manage_sql/manage_sql.py index 5b3fe3e..46c99aa 100755 --- a/manage_sql/manage_sql.py +++ b/manage_sql/manage_sql.py @@ -15,7 +15,7 @@ from configparser import SafeConfigParser import pymysql # Read conf.ini -INI_CONF = "./conf.ini" +INI_CONF = "./config/conf.ini" CONFIG = SafeConfigParser() CONFIG.read(INI_CONF) @@ -30,7 +30,7 @@ class HandleSql: """Class to handle sql connection.""" @staticmethod - def sql_check(): + def sql_checkcon(): """Init sql connection.""" try: global conn diff --git a/test.py b/test.py index 708a8a9..ceee86a 100644 --- a/test.py +++ b/test.py @@ -3,7 +3,11 @@ from manage_sql.manage_sql import HandleSql -MY_PSQL_CONN = HandleSql() +MY_SQL_CONN = HandleSql() -check_return_bdd = MY_PSQL_CONN.psql_checkcon() -print(check_return_bdd) \ No newline at end of file +try: + check_return_bdd = MY_SQL_CONN.sql_checkcon() +except OperationalError as error: + print(error) +else: + print(check_return_bdd)