notebookVB
This commit is contained in:
@@ -17,7 +17,8 @@ SOAP_NS = "http://schemas.xmlsoap.org/soap/envelope/"
|
|||||||
NS_STAV = "http://xmlns.gemsystem.cz/stavPojisteniB2B"
|
NS_STAV = "http://xmlns.gemsystem.cz/stavPojisteniB2B"
|
||||||
|
|
||||||
# RC provided by you (can contain slash; we normalize before sending/saving)
|
# RC provided by you (can contain slash; we normalize before sending/saving)
|
||||||
RC = "280616/091"
|
RC = "7309208104"
|
||||||
|
# RC = "280616/091"
|
||||||
K_DATU = date.today().isoformat()
|
K_DATU = date.today().isoformat()
|
||||||
|
|
||||||
# MySQL (table already created as per previous DDL)
|
# MySQL (table already created as per previous DDL)
|
||||||
|
|||||||
46
03 Vyber.py
Normal file
46
03 Vyber.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
from functions import get_medicus_connection
|
||||||
|
from functions import get_mysql_connection
|
||||||
|
from functions import check_insurance
|
||||||
|
import time
|
||||||
|
|
||||||
|
def prepare_processed_rcs():
|
||||||
|
consql=get_mysql_connection()
|
||||||
|
cursql=consql.cursor()
|
||||||
|
|
||||||
|
sql="""
|
||||||
|
WITH ranked AS (
|
||||||
|
SELECT
|
||||||
|
vr.*,
|
||||||
|
ROW_NUMBER() OVER (
|
||||||
|
PARTITION BY rc
|
||||||
|
ORDER BY k_datu DESC, queried_at DESC
|
||||||
|
) AS rn
|
||||||
|
FROM vzp_stav_pojisteni AS vr
|
||||||
|
)
|
||||||
|
SELECT rc
|
||||||
|
FROM ranked
|
||||||
|
WHERE rn = 1
|
||||||
|
"""
|
||||||
|
|
||||||
|
cursql.execute(sql)
|
||||||
|
rows=cursql.fetchall()
|
||||||
|
print(f"Pocet jiz zpracovanych rodnych cisel v MYSQL MEDEVIO je {len(rows)}")
|
||||||
|
rc_set_vzp = {row["rc"] for row in rows}
|
||||||
|
return (rc_set_vzp)
|
||||||
|
|
||||||
|
con=get_medicus_connection()
|
||||||
|
cur=con.cursor()
|
||||||
|
cur.execute("select rodcis, prijmeni, jmeno from kar where rodcis starting with '7'")
|
||||||
|
|
||||||
|
rc_set_vzp=prepare_processed_rcs()
|
||||||
|
|
||||||
|
rows=cur.fetchall()
|
||||||
|
print(f"Pocet vybranych radku z tabulky KAR je: {len(rows)}")
|
||||||
|
|
||||||
|
for row in rows:
|
||||||
|
if row[0] in rc_set_vzp:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
print(row[0], row[1],row[2])
|
||||||
|
print(check_insurance(row[0]))
|
||||||
|
time.sleep(5)
|
||||||
7
04 testik.py
Normal file
7
04 testik.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from functions import check_insurance
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
rc = "7309208104"
|
||||||
|
res = check_insurance(rc)
|
||||||
|
print("=== RESULT ===")
|
||||||
|
print(res)
|
||||||
42
functions.py
42
functions.py
@@ -11,6 +11,48 @@ import requests
|
|||||||
from requests_pkcs12 import Pkcs12Adapter
|
from requests_pkcs12 import Pkcs12Adapter
|
||||||
import pymysql
|
import pymysql
|
||||||
from pymysql.cursors import DictCursor
|
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) ========
|
# ======== CONFIG (env overrides allowed) ========
|
||||||
PFX_PATH = os.getenv("VZP_PFX_PATH", r"mbcert.pfx")
|
PFX_PATH = os.getenv("VZP_PFX_PATH", r"mbcert.pfx")
|
||||||
|
|||||||
Reference in New Issue
Block a user