yym68686 commited on
Commit
90a8f67
·
1 Parent(s): 1d1b0f1

🐛 Bug: Fix the bug where the database cannot be automatically created when it does not exist

Browse files
Files changed (1) hide show
  1. main.py +3 -0
main.py CHANGED
@@ -31,6 +31,9 @@ async def create_tables():
31
  @asynccontextmanager
32
  async def lifespan(app: FastAPI):
33
  # 启动时的代码
 
 
 
34
  await create_tables()
35
 
36
  TIMEOUT = float(os.getenv("TIMEOUT", 100))
 
31
  @asynccontextmanager
32
  async def lifespan(app: FastAPI):
33
  # 启动时的代码
34
+ if not os.path.exists("stats.db"):
35
+ # 如果数据库文件不存在,创建它
36
+ open("stats.db", 'a').close()
37
  await create_tables()
38
 
39
  TIMEOUT = float(os.getenv("TIMEOUT", 100))