We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 137e7e5 commit 17b823bCopy full SHA for 17b823b
models.py
@@ -3,6 +3,7 @@
3
from sqlalchemy.ext.declarative import declarative_base
4
from sqlalchemy.orm import sessionmaker
5
import enum
6
+import os
7
8
Base = declarative_base()
9
@@ -71,7 +72,9 @@ def to_dict(self):
71
72
73
74
# 数据库配置
-DATABASE_URL = 'sqlite:///notify_scheduler.db'
75
+default_db_path = os.path.join(os.getenv('DATA_DIR', 'data'), 'notify_scheduler.db')
76
+os.makedirs(os.path.dirname(default_db_path), exist_ok=True)
77
+DATABASE_URL = os.getenv('DATABASE_URL', f"sqlite:///{default_db_path}")
78
engine = create_engine(DATABASE_URL, echo=True)
79
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
80
0 commit comments