Skip to content

Commit

Permalink
fix: 数据库并发修复
Browse files Browse the repository at this point in the history
  • Loading branch information
linyuan0213 committed Jul 12, 2024
1 parent 1fe6562 commit fc763b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ def update_db():
alembic_upgrade(alembic_cfg, 'head')
log.console('数据库更新完成')
except Exception as e:
log.console(f'数据库更新失败:{e}')
pass
8 changes: 7 additions & 1 deletion app/db/main_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
pool_pre_ping=True,
pool_size=150,
pool_recycle=60 * 10,
max_overflow=10
max_overflow=10,
connect_args={'timeout': 30}
)

# 启用 WAL 模式
with _Engine.connect() as conn:
conn.execute(text("PRAGMA journal_mode=WAL;"))

_Session = scoped_session(sessionmaker(bind=_Engine,
autoflush=True,
autocommit=False,
Expand Down

0 comments on commit fc763b5

Please sign in to comment.