mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
modularize src
+ merge main.py and manage.py + move start logic to swingmusic/__main__.py + add a run.py on the project root
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
Module to setup Sqlite databases and tables.
|
||||
Applies migrations.
|
||||
"""
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from swingmusic.db.userdata import UserTable
|
||||
from swingmusic.migrations import apply_migrations
|
||||
from swingmusic.settings import DbPaths
|
||||
|
||||
from swingmusic.db.engine import DbEngine
|
||||
from swingmusic.db import create_all_tables
|
||||
# from swingmusic.db.libdata import create_all as create_user_tables
|
||||
|
||||
|
||||
def run_migrations():
|
||||
"""
|
||||
Run migrations and updates migration version.
|
||||
"""
|
||||
apply_migrations()
|
||||
|
||||
|
||||
def setup_sqlite():
|
||||
"""
|
||||
Create Sqlite databases and tables.
|
||||
"""
|
||||
DbEngine._engine = create_engine(
|
||||
f"sqlite+pysqlite:///{DbPaths.get_app_db_path()}",
|
||||
echo=False,
|
||||
max_overflow=20,
|
||||
pool_size=10,
|
||||
)
|
||||
|
||||
create_all_tables()
|
||||
# create_user_tables()
|
||||
|
||||
if not list(UserTable.get_all()):
|
||||
UserTable.insert_default_user()
|
||||
Reference in New Issue
Block a user