Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ssttkkl committed Oct 30, 2022
2 parents 6235475 + f8e9f0f commit 884f79c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ login_matcher = on_command("login")
async def handler(event: MessageEvent, matcher: Matcher):
username, password = event.get_plaintext().split(" ")

# 此处获取的session实际上是async_scoped_session
# 在Matcher的一次执行过程中,多次调用data_source.session()获得的是同一个session,并且会在Matcher执行完毕后自动关闭
# 参考:https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html#using-asyncio-scoped-session
session = data_source.session()

stmt = select(UserOrm).where(UserOrm.username == username, UserOrm.password == password)
Expand Down

0 comments on commit 884f79c

Please sign in to comment.