Skip to content

Commit ca9acb4

Browse files
committed
initialize db automatically on start
1 parent 4a83203 commit ca9acb4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

backend/db_init.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from config import config
1919

2020

21-
def main():
21+
def db_init():
2222
Path(path_split(config["database_path"])[0]).mkdir(parents=True, exist_ok=True)
2323

2424
with SQLiteHandler() as cur:
@@ -61,4 +61,4 @@ def main():
6161

6262

6363
if __name__ == "__main__":
64-
main()
64+
db_init()

backend/main.py

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
from pydantic_models import Event
99
from jwt_coder import jwt_encode, get_user_id, check_token_admin, check_token_admin_deco
1010
from hashing import to_hash
11+
from db_init import db_init
12+
13+
14+
# initialize the database (will not overwrite)
15+
db_init()
1116

1217

1318
app = FastAPI()

0 commit comments

Comments
 (0)