Skip to content

Commit

Permalink
Merge pull request #230 from Crinibus/add-database
Browse files Browse the repository at this point in the history
Hotfix - Ensure the folder for the database exists else create it
  • Loading branch information
Crinibus authored Nov 17, 2023
2 parents 964d546 + cc5996e commit fcaa6b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions scraper/database/db.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from sqlmodel import SQLModel, create_engine
from pathlib import Path
from scraper.filemanager import Filemanager
from .models import Product, DataPoint # noqa: F401

sqlite_url = f"sqlite:///{Filemanager.database_path}"

Path(Filemanager.database_folder).mkdir(exist_ok=True)

engine = create_engine(sqlite_url, echo=False)


Expand Down
3 changes: 2 additions & 1 deletion scraper/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Filemanager:
settings_ini_path = f"{root_path}/scraper/settings.ini"
logging_ini_path = f"{root_path}/scraper/logging.ini"
logfile_path = f"{root_path}/scraper/logfile.log"
database_path = f"{root_path}/scraper/data/database.db"
database_folder = f"{root_path}/scraper/data"
database_path = f"{database_folder}/database.db"


class Config:
Expand Down

0 comments on commit fcaa6b5

Please sign in to comment.