コード例 #1
0
async def create_member(conn, system_id: int, member_name: str,
                        member_hid: str) -> Member:
    logger.debug("Creating member (system={}, name={}, hid={})".format(
        system_id, member_name, member_hid))
    row = await conn.fetchrow(
        "insert into members (name, system, hid) values ($1, $2, $3) returning *",
        member_name, system_id, member_hid)
    return Member(**row) if row else None
コード例 #2
0
async def get_all_members(conn, system_id: int) -> List[Member]:
    rows = await conn.fetch("select * from members where system = $1",
                            system_id)
    return [Member(**row) for row in rows]
コード例 #3
0
async def get_members_exceeding(conn, system_id: int,
                                length: int) -> List[Member]:
    rows = await conn.fetch(
        "select * from members where system = $1 and length(name) > $2",
        system_id, length)
    return [Member(**row) for row in rows]
コード例 #4
0
async def get_members(conn, members: list) -> List[Member]:
    rows = await conn.fetch("select * from members where id = any($1)",
                            members)
    return [Member(**row) for row in rows]
コード例 #5
0
async def get_member(conn, member_id: int) -> Member:
    row = await conn.fetchrow("select * from members where id = $1", member_id)
    return Member(**row) if row else None
コード例 #6
0
async def get_member_by_hid(conn, member_hid: str) -> Member:
    row = await conn.fetchrow("select * from members where hid = $1",
                              member_hid)
    return Member(**row) if row else None
コード例 #7
0
async def get_member_by_hid_in_system(conn, system_id: int,
                                      member_hid: str) -> Member:
    row = await conn.fetchrow(
        "select * from members where system = $1 and hid = $2", system_id,
        member_hid)
    return Member(**row) if row else None
コード例 #8
0
async def get_member_by_name(conn, system_id: int, member_name: str) -> Member:
    row = await conn.fetchrow(
        "select * from members where system = $1 and lower(name) = lower($2)",
        system_id, member_name)
    return Member(**row) if row else None