def guild_get_by_id(gid) -> Optional[DbGuild]: c.execute("SELECT * FROM guilds WHERE id=?", (gid,)) g = c.fetchone() return DbGuild(*g) if g else None
def guild_get_by_faction_name(name) -> Optional[DbGuild]: c.execute("SELECT * FROM guilds WHERE faction_name=?", (name,)) g = c.fetchone() return DbGuild(*g) if g else None
def guild_get_all_factions() -> List[DbGuild]: c.execute("SELECT * FROM guilds WHERE faction_name IS NOT NULL ORDER BY faction_name") return [DbGuild(*g) for g in c.fetchall()]
def guild_get_by_faction_alias(alias) -> Optional[DbGuild]: c.execute("SELECT * FROM guilds WHERE faction_alias=?", (alias,)) g = c.fetchone() return DbGuild(*g) if g else None
def guild_get_all() -> List[DbGuild]: c.execute("SELECT * FROM guilds") return [DbGuild(*g) for g in c.fetchall()]