diff --git a/.gitignore b/.gitignore index e7714e2..43547e0 100644 --- a/.gitignore +++ b/.gitignore @@ -49,8 +49,7 @@ nb-configuration.xml __pycache__/ .pytest_cache *.py[cod] -.env/ -.env* +.env .~env/ .venv env3.6/ diff --git a/pixi.lock b/pixi.lock index 73940cd..ba07af5 100644 --- a/pixi.lock +++ b/pixi.lock @@ -38,6 +38,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/plotly-5.24.1-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.13.0-h9ebbce0_100_cp313.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0-pyhd8ed1ab_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.0.1-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/python-duckdb-1.1.2-py313h46c70d0_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-tzdata-2024.2-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/python_abi-3.13-5_cp313.conda @@ -74,6 +75,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/plotly-5.24.1-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/python-3.13.0-h0608dab_100_cp313.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0-pyhd8ed1ab_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.0.1-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/python-duckdb-1.1.2-py313hc1eae12_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-tzdata-2024.2-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/python_abi-3.13-5_cp313.conda @@ -110,6 +112,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/plotly-5.24.1-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.13.0-h75c3a9f_100_cp313.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0-pyhd8ed1ab_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.0.1-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-duckdb-1.1.2-py313h4e5f155_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-tzdata-2024.2-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/python_abi-3.13-5_cp313.conda @@ -146,6 +149,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/pthreads-win32-2.9.1-h2466b09_4.conda - conda: https://conda.anaconda.org/conda-forge/win-64/python-3.13.0-hf5aa216_100_cp313.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0-pyhd8ed1ab_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.0.1-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/python-duckdb-1.1.2-py313h5813708_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-tzdata-2024.2-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/python_abi-3.13-5_cp313.conda @@ -312,7 +316,7 @@ packages: name: consultancy-2 version: 0.1.0 path: . - sha256: 1858b9f8c1dc159a388e18243329187b239c647b7923868f73227b841e330a3e + sha256: 6ffb42ba9596cdfd1545aaa22cb3cd8f9f1c1418b1ac2dbe95f4c00b598b0af9 requires_python: '>=3.11' editable: true - kind: conda @@ -1847,6 +1851,23 @@ packages: - pkg:pypi/python-dateutil?source=hash-mapping size: 222742 timestamp: 1709299922152 +- kind: conda + name: python-dotenv + version: 1.0.1 + build: pyhd8ed1ab_0 + subdir: noarch + noarch: python + url: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.0.1-pyhd8ed1ab_0.conda + sha256: 2d4c80364f03315d606a50eddd493dbacc078e21412c2462c0f781eec49b572c + md5: c2997ea9360ac4e015658804a7a84f94 + depends: + - python >=3.8 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/python-dotenv?source=hash-mapping + size: 24278 + timestamp: 1706018281544 - kind: conda name: python-duckdb version: 1.1.2 diff --git a/pyproject.toml b/pyproject.toml index 778df4a..9d05c2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,3 +24,4 @@ numpy = ">=2.1.2,<3" pandas = ">=2.2.3,<3" plotly = ">=5.24.1,<6" duckdb = ">=1.1.2,<2" +python-dotenv = ">=1.0.1,<2" diff --git a/src/.env.example b/src/.env.example new file mode 100644 index 0000000..af889cf --- /dev/null +++ b/src/.env.example @@ -0,0 +1 @@ +DATABASE="/full/path/to/databse.duckdb" diff --git a/src/data/__init__.py b/src/data/__init__.py index 9368496..83dafbd 100644 --- a/src/data/__init__.py +++ b/src/data/__init__.py @@ -1,5 +1,10 @@ +import os + +from dotenv import load_dotenv + from data import database +load_dotenv(dotenv_path='../.env') def load(): - return database.Database() \ No newline at end of file + return database.Database(path=os.getenv('DATABASE')) \ No newline at end of file diff --git a/src/data/database.py b/src/data/database.py index e788613..ad520b1 100644 --- a/src/data/database.py +++ b/src/data/database.py @@ -2,8 +2,8 @@ import duckdb class Database: - def __init__(self): - self.connection = duckdb.connect(database = '../data/consultancy.duckdb', read_only = True) + def __init__(self, path): + self.connection = duckdb.connect(database = path, read_only = True) def db_overview(self): return self.connection.sql("DESCRIBE;").show()