handling with .env file

This commit is contained in:
2026-05-26 12:17:49 +02:00
parent 078cfee7ed
commit 76a9bd4329
6 changed files with 34 additions and 21 deletions

2
pdm.lock generated
View File

@@ -5,7 +5,7 @@
groups = ["default", "dev", "lint", "nb", "tests"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
content_hash = "sha256:b66d3ee47e9636e1e92ea7537bb7d2795d91d77c2d80303a61b8da2fe0315570"
content_hash = "sha256:4adb42a7279939be5798107003c3b108795194e4405ea5cda4ab67f048464df7"
[[metadata.targets]]
requires_python = ">=3.11,<3.14"

View File

@@ -5,7 +5,7 @@ description = "GUI for CRM of NAFKA project with WCE"
authors = [
{name = "d-opt GmbH, resp. Florian Förster", email = "f.foerster@d-opt.com"},
]
dependencies = ["nicegui>=3.10.0", "pyside6>=6.11.0", "sqlalchemy>=2.0.49", "polars>=1.40.1", "dopt-basics>=0.2.5", "pydantic[email]>=2.13.4", "babel>=2.18.0"]
dependencies = ["nicegui>=3.10.0", "pyside6>=6.11.0", "sqlalchemy>=2.0.49", "polars>=1.40.1", "dopt-basics>=0.2.5", "pydantic[email]>=2.13.4", "babel>=2.18.0", "python-dotenv>=1.2.2"]
requires-python = "<3.14,>=3.11"
readme = "README.md"
license = {text = "LicenseRef-Proprietary"}

View File

@@ -1,3 +1 @@
import wce_crm.env
wce_crm.env.setup()

View File

@@ -1,6 +1,34 @@
from __future__ import annotations
import os
from pathlib import Path
from typing import Final
LIB_PATH: Final[Path] = Path(__file__).parent
import dotenv
from dopt_basics import io as io_
dotenv.load_dotenv()
PROJECT_ROOT = Path(__file__).resolve().parents[2]
LIB_PATH: Final[Path] = Path(__file__).resolve().parent
DEV_DB_PATH = PROJECT_ROOT / "data/db"
DEV_DB_KONTAKTLISTE = DEV_DB_PATH / "wce_kontaktliste.db"
assert DEV_DB_KONTAKTLISTE.exists()
DEV_DB_CRM = DEV_DB_PATH / "wce_crm.db"
assert DEV_DB_CRM.exists()
BASE_PATH = io_.search_folder_path(
LIB_PATH, stop_folder_name=os.getenv("DOPT_STOP_FOLDER_NAME", "python")
)
assert BASE_PATH
class Config:
DB_PATH_CRM = BASE_PATH / os.getenv("DOPT_DB_CRM", "data/db/wce_crm.db")
DB_PATH_MAIN = BASE_PATH / os.getenv("DOPT_DB_MAIN", "data/db/wce_grunderfassung.db")
# def setup():
# os.environ["DOPT_DB_KONTAKTLISTE"] = str(DEV_DB_KONTAKTLISTE)
# os.environ["DOPT_DB_CRM"] = str(DEV_DB_CRM)

View File

@@ -1,15 +1 @@
import os
from pathlib import Path
PROJECT_ROOT = Path(__file__).parents[2]
DB_PATH = PROJECT_ROOT / "data/db"
DB_KONTAKTLISTE = DB_PATH / "wce_kontaktliste.db"
assert DB_KONTAKTLISTE.exists()
DB_CRM = DB_PATH / "wce_crm.db"
assert DB_CRM.exists()
def setup():
os.environ["DOPT_DB_KONTAKTLISTE"] = str(DB_KONTAKTLISTE)
os.environ["DOPT_DB_CRM"] = str(DB_CRM)

View File

@@ -1,2 +1,3 @@
DOPT_DB_KONTAKTLISTE: Pfad zur Datenbank der Kontaktliste, falls nicht direkt übergeben (Prototypenphase)
DOPT_DB_CRM: Pfad zur CRM-Datenbank, falls nicht direkt übergeben (Prototypenphase)
DOPT_STOP_FOLDER_NAME: stop folder to find base path
DOPT_DB_CRM: path to CRM database, relative to base path
DOPT_DB_MAIN: path to main database, relative to base path