model.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:dcss-scoreboard 作者: zxc23 项目源码 文件源码
def get_account_id(s: sqlalchemy.orm.session.Session,
                   name: str,
                   server: Server) -> int:
    """Get an account id, creating the account if needed.

    Note that player names are not case sensitive, so names are stored with
    their canonical capitalisation but we always compare the lowercase version.
    """
    player_id = get_player_id(s, name)
    acc = s.query(Account.id).filter(
        func.lower(Account.name) == name.lower(),
        Account.server == server).one_or_none()
    if acc:
        return acc[0]
    else:
        acc = Account(name=name, server=server, player_id=player_id)
        s.add(acc)
        s.commit()
        return acc.id
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号