Ejemplo n.º 1
0
def delete_from_basicmodel(column_2_value):
    try:
        to_be_deleted_object = Session.query(BasicModel).filter_by(
            column_2=column_2_value).first()
        Session.delete(to_be_deleted_object)
        return "Succesfully deleted!!"
    except:
        Session.rollback()
        return "Something unexpected happened, rolledback operation"
Ejemplo n.º 2
0
def update_basicmodel(old_column_1_value, new_column_1_value):
    try:
        ol_baicmodel_object = Session.query(BasicModel).filter_by(
            column_1=old_column_1_value).first()
        ol_baicmodel_object.column_1 = new_column_1_value
        Session.commit()
        return "Sucessfully updated"
    except:
        Session.rollback()
        return "Something unexpected happened, rolledback operation"
Ejemplo n.º 3
0
def add_to_basicmodel(column_1_value, column_2_value, column_3_value):
    try:
        new_basicmodel_object = BasicModel(column_1=column_1_value,
                                           column_2=column_2_value,
                                           column_3=column_3_value)
        Session.add(new_basicmodel_object)
        Session.commit()
        return "Sucessfully added"
    except:
        Session.rollback()
        return "Something unexpected happened, rolledback operation"
Ejemplo n.º 4
0
    def create_account_by_chat_id(self, chat_id: str, username: str):
        session = Session()

        instance = session.query(AccountModel).filter_by(
            chat_id=chat_id, ).one_or_none()
        if instance:
            return

        account_model = AccountModel(chat_id=chat_id, username=username)

        try:
            session.add(account_model)
            session.commit()
        except Exception:
            session.rollback()