def update_time_subscription(id_user: int, time_str: str) -> None: date_time = "{} {}".format(tomorrow_date(), time_str) date_time = datetime.datetime.strptime(date_time, "%Y-%m-%d %H:%M") db_session.query(Users).filter(Users.id_user == id_user).update( {"subscription": date_time}) db_session.commit()
def add_pr_data(name, url, text, path_image): obj = PR_modul(name, url, text, path_image) db_session.add(obj) try: db_session.commit() except sqlite3.IntegrityError: db_session.rollback() db_session.close() except sqlalchemy.exc.IntegrityError: db_session.rollback() db_session.close()
def add_coord(id_user: int, city: str, country_cod: str, lat: float, lon: float, timezone: int) -> None: obj = Users(id_user, city, country_cod, lat, lon, timezone, None) db_session.add(obj) try: db_session.commit() except sqlite3.IntegrityError: db_session.rollback() db_session.close() update_coord(id_user, city, country_cod, lat, lon, timezone) except sqlalchemy.exc.IntegrityError: db_session.rollback() db_session.close() update_coord(id_user, city, country_cod, lat, lon, timezone)
def update_coord(id_user: int, city: str, country_cod: str, lat: float, lon: float, timezone: int) -> None: db_session.query(Users).filter(Users.id_user == id_user).update({ "city": city, "country_cod": country_cod, "lat": lat, "lon": lon, "timezone": timezone, }) db_session.commit()
def update_city_user(id_user, city): db_session.query(Users).filter(Users.id_user == id_user).update( {"city": city}) db_session.commit()
def update_country_cod(id_user: int, country_cod: str) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"country_cod": country_cod}) db_session.commit()
def update_city(id_user: int, city: str) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"city": city}) db_session.commit()
def dell_sub(id_user): db_session.query(Users).filter(Users.id_user == id_user).delete() db_session.commit()
def update_time_sub(id_user: int, time_sub_user: datetime) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"subscription": time_sub_user + datetime.timedelta(hours=24)}) db_session.commit()
def update_data_sity_dict(id_user: int, data_sity_dict: dict) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"data_sity_dict": str(data_sity_dict)}) db_session.commit()
def updete_status(id_user: int, status: int) -> None: db_session.query(Users).filter(Users.id_user == id_user).update( {"status": status}) db_session.commit()