summaryrefslogtreecommitdiff
path: root/shopdb/_base.py
blob: 5e8c3bca869af237331b0e2b5c7c1d70621cda7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
__all__ = ["engine", "Base", "Session"]


import appdirs
import pathlib
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker



path = pathlib.Path(appdirs.user_data_dir(appname="shopdb")) / "sqlite3.db"
path.parent.mkdir(parents=True, exist_ok=True)
engine = sqlalchemy.create_engine(f"sqlite:///{path}", echo=False)

Base = declarative_base()

Session = sessionmaker(bind=engine)