notebookVB
This commit is contained in:
42
functions.py
42
functions.py
@@ -11,6 +11,48 @@ import requests
|
||||
from requests_pkcs12 import Pkcs12Adapter
|
||||
import pymysql
|
||||
from pymysql.cursors import DictCursor
|
||||
import fdb
|
||||
|
||||
MEDICUS_CFG = dict(
|
||||
dsn=r"192.168.1.4:z:\medicus 3\data\medicus.fdb",
|
||||
user="SYSDBA",
|
||||
password="masterkey",
|
||||
charset="win1250",
|
||||
)
|
||||
|
||||
def get_medicus_connection():
|
||||
"""
|
||||
Attempt to create a Firebird connection to the Medicus database.
|
||||
Returns:
|
||||
fdb.Connection object on success
|
||||
None on failure
|
||||
"""
|
||||
try:
|
||||
return fdb.connect(**MEDICUS_CFG)
|
||||
except fdb.fbcore.DatabaseError as e:
|
||||
print(f"Medicus DB connection failed: {e}")
|
||||
return None
|
||||
|
||||
# -------- MySQL (Medevio, etc.) -------
|
||||
MYSQL_CFG = dict(
|
||||
host="192.168.1.76",
|
||||
port=3307,
|
||||
user="root",
|
||||
password="Vlado9674+",
|
||||
database="medevio",
|
||||
cursorclass=DictCursor,
|
||||
autocommit=True, # or False if you prefer manual commit
|
||||
)
|
||||
|
||||
def get_mysql_connection():
|
||||
"""
|
||||
Return a PyMySQL connection or None if the connection fails.
|
||||
"""
|
||||
try:
|
||||
return pymysql.connect(**MYSQL_CFG)
|
||||
except pymysql.MySQLError as e:
|
||||
print(f"MySQL connection failed: {e}")
|
||||
return None
|
||||
|
||||
# ======== CONFIG (env overrides allowed) ========
|
||||
PFX_PATH = os.getenv("VZP_PFX_PATH", r"mbcert.pfx")
|
||||
|
||||
Reference in New Issue
Block a user