Browse Source

Maj module

pull/1/head
Boris Tassou 3 years ago
parent
commit
918de9e524
  1. 2
      .gitignore
  2. 0
      config/conf.ini.sample
  3. 2
      manage_sql/__init__.py
  4. BIN
      manage_sql/__pycache__/__init__.cpython-36.pyc
  5. BIN
      manage_sql/__pycache__/manage_sql.cpython-36.pyc
  6. 5
      manage_sql/conf.ini
  7. 4
      manage_sql/manage_sql.py
  8. 10
      test.py

2
.gitignore vendored

@ -1 +1 @@ @@ -1 +1 @@
conf.ini
config/conf.ini

0
manage_sql/conf.ini.sample → config/conf.ini.sample

2
manage_sql/__init__.py

@ -21,5 +21,5 @@ __license__ = 'Beerware' @@ -21,5 +21,5 @@ __license__ = 'Beerware'
try:
import pymysql
except ImportError:
print('PyMSQL library not found')
print('PyMYSQL library not found')
sys.exit(1)

BIN
manage_sql/__pycache__/__init__.cpython-36.pyc

Binary file not shown.

BIN
manage_sql/__pycache__/manage_sql.cpython-36.pyc

Binary file not shown.

5
manage_sql/conf.ini

@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
[sql]
host=localhost
database=adherents_services
user=root
passwd=Boris1989!

4
manage_sql/manage_sql.py

@ -15,7 +15,7 @@ from configparser import SafeConfigParser @@ -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: @@ -30,7 +30,7 @@ class HandleSql:
"""Class to handle sql connection."""
@staticmethod
def sql_check():
def sql_checkcon():
"""Init sql connection."""
try:
global conn

10
test.py

@ -3,7 +3,11 @@ @@ -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)
try:
check_return_bdd = MY_SQL_CONN.sql_checkcon()
except OperationalError as error:
print(error)
else:
print(check_return_bdd)

Loading…
Cancel
Save