-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c5da19
commit a1cebd1
Showing
3 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Database: Manages connection and sessions for SQLite database.""" | ||
import sqlalchemy as _sql | ||
|
||
import sqlalchemy.ext.declarative as _declarative | ||
import sqlalchemy.orm as _orm | ||
|
||
# database connection string | ||
SQLALCHEMY_DATABASE_URL = "sqlite:///./database.db" | ||
|
||
# engine for connecting to the database | ||
ENGINE: _sql.Engine = _sql.create_engine( | ||
url=SQLALCHEMY_DATABASE_URL, | ||
connect_args={"check_same_thread":False} | ||
) | ||
|
||
# session maker for opening database sessions | ||
SESSION_LOCAL = _orm.sessionmaker( | ||
bind=ENGINE, # bind the session maker to the engine | ||
autoflush=False, # disable automatic flushing for performance optimization | ||
autocommit=False # prevent automatic commits for better control | ||
) | ||
|
||
# base class for your database models | ||
BASE = _declarative.declarative_base() |