def in_channels(chat_id): try: return SESSION.query(fban).filter(fban.chat_id == str(chat_id)).one() except BaseException: return None finally: SESSION.close()
def already_added(chat_id): try: return SESSION.query(Moidata).filter( Moidata.chat_id == str(chat_id)).one() except: return None finally: SESSION.close()
def get_all_channels(): rem = SESSION.query(fban).all() SESSION.close() return rem
def rm_channel(chat_id): rem = SESSION.query(fban).get(str(chat_id)) if rem: SESSION.delete(rem) SESSION.commit()
def add_channel(chat_id): adder = fban(str(chat_id)) SESSION.add(adder) SESSION.commit()
def get_all_users(): stark = SESSION.query(Moidata).all() SESSION.close() return stark
def add_usersid_in_db(chat_id: int): id_user = Moidata(str(chat_id)) SESSION.add(id_user) SESSION.commit()