Skip to content

Commit 9bd7d13

Browse files
author
dreamer43
committed
修复数据库目录可能不存在的bug
1 parent 5c66576 commit 9bd7d13

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
os.environ['DEEPSEEK_API_BASE'] = DEFAULT_CONFIG["api_base"]
5353

5454
# 数据库配置
55-
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "instance", "aigument.db")}'
55+
# 确保instance目录存在
56+
instance_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "instance")
57+
os.makedirs(instance_dir, exist_ok=True)
58+
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{os.path.join(instance_dir, "aigument.db")}'
5659
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
5760

5861
# 初始化数据库

0 commit comments

Comments
 (0)