Пример #1
0
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()
Пример #2
0
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()
Пример #3
0
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)
Пример #4
0
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()
Пример #5
0
def update_city_user(id_user, city):
    db_session.query(Users).filter(Users.id_user == id_user).update(
        {"city": city})
    db_session.commit()
Пример #6
0
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()
Пример #7
0
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()
Пример #8
0
def dell_sub(id_user):
    db_session.query(Users).filter(Users.id_user == id_user).delete()
    db_session.commit()
Пример #9
0
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()
Пример #10
0
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()
Пример #11
0
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()