def lookup_user_by_telegram_handle(telegram_handle): telegram_handle = telegram_handle.lower().replace("@", "") session = create_session() bot_user = (session.query(User).filter( User.telegram_handle == telegram_handle).first()) session.close() return bot_user
def lookup_user_by_account_id(account_id): account_id = int(account_id) session = create_session() bot_user = session.query(User).filter( User.account_id == account_id).first() session.close() return bot_user
def get_item_by_id(item_id): session = create_session() output = session.query(Item).filter(Item.id == item_id).first() session.close() return output
def get_item_by_name(item_name): session = create_session() output = session.query(Item).filter( Item.item_name == item_name.lower()).first() session.close() return output
def save_user(user): session = create_session() session.add(user) session.commit()
def lookup_user_by_telegram_handle(telegram_handle): session = create_session() bot_user = (session.query(User).filter( User.telegram_handle == telegram_handle).first()) return bot_user
def save_user(user): user.telegram_handle = user.telegram_handle.lower() session = create_session() session.merge(user) session.commit()
def get_hero_by_name(hero_name): session = create_session() output = session.query(Hero).filter( Hero.localized_name.ilike(hero_name)).first() session.close() return output
def get_hero_aliases_by_hero_id(hero_id): session = create_session() output = session.query(HeroAlias).filter( HeroAlias.hero_id == hero_id).all() session.close() return output
def get_hero_alias_by_name(hero_alias): session = create_session() output = session.query(HeroAlias).filter( HeroAlias.alias.ilike(hero_alias)).first() session.close() return output
def get_hero_by_id(hero_id): session = create_session() output = session.query(Hero).filter(Hero.id == hero_id).first() session.close() return output