lenovo
This commit is contained in:
+21
-9
@@ -1,11 +1,11 @@
|
||||
import firebirdsql as fb
|
||||
import firebirdsql as fb,os
|
||||
import pandas as pd
|
||||
|
||||
# TCP to the Firebird 2.5 server. Use the DB path as seen by the *server* (Windows path).
|
||||
conn = fb.connect(
|
||||
host="192.168.1.4",
|
||||
host="192.168.1.10",
|
||||
port=3050,
|
||||
database=r"z:\Medicus 3\data\MEDICUS.FDB", # raw string for backslashes
|
||||
database=r"m:\Medicus\data\MEDICUS.FDB", # raw string for backslashes
|
||||
user="SYSDBA",
|
||||
password="masterkey",
|
||||
charset="WIN1250", # adjust if needed
|
||||
@@ -49,7 +49,7 @@ SELECT
|
||||
FROM dokladd dd
|
||||
WHERE dd.rodcis = kar.rodcis
|
||||
AND (dd.kod = '01130' or dd.kod = '01131' OR dd.kod = '01132' OR dd.kod = '01133' OR dd.kod = '01134')
|
||||
AND dd.datose BETWEEN vh.datum - 7 AND vh.datum + 7
|
||||
AND dd.datose BETWEEN vh.datum - 365 AND vh.datum + 365
|
||||
) AS vykodovano,
|
||||
lm.kodtext,
|
||||
lm.nazev,
|
||||
@@ -119,11 +119,23 @@ from openpyxl.formatting.rule import ColorScaleRule
|
||||
from openpyxl.styles import PatternFill
|
||||
from openpyxl.formatting.rule import FormulaRule
|
||||
|
||||
# ---- 1) Build timestamped output path ----
|
||||
base_path = Path("u:\Dropbox\!!!Days\Downloads Z230")
|
||||
base_path.mkdir(parents=True, exist_ok=True) # ensure folder exists
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
output_file = base_path / f"lab_results_2025_{timestamp}.xlsx"
|
||||
|
||||
base_path = Path(r"z:\Dropbox\Ordinace\Reporty")
|
||||
base_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# ================= DELETE OLD PSA REPORTS ==================
|
||||
for fname in os.listdir(base_path):
|
||||
if fname.endswith("PSA report.xlsx"):
|
||||
try:
|
||||
os.remove(base_path / fname)
|
||||
print(f"🗑️ Deleted old PSA report: {fname}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ Could not delete {fname}: {e}")
|
||||
|
||||
# ================= CREATE NEW FILENAME ==================
|
||||
timestamp = datetime.now().strftime("%Y-%m-%d %H-%M-%S")
|
||||
output_file = base_path / f"{timestamp} PSA report.xlsx"
|
||||
print(f"📄 New PSA report will be saved as: {output_file}")
|
||||
|
||||
# ---- 2) Export DataFrame to Excel ----
|
||||
# Assumes df_direct already exists (your joined query result)
|
||||
|
||||
Reference in New Issue
Block a user