Example #1
0
def delete(source_: Source):
    if source_.pipelines:
        raise Exception(
            f"Can't delete. Source is used by {', '.join([p.name for p in source_.pipelines])} pipelines"
        )
    Session.delete(source_)
    Session.commit()
Example #2
0
class SessionManager:
    def __init__(self, entity):
        self.entity = entity
        self.session = Session()
        if not self.session.object_session(self.entity):
            self.session.add(self.entity)

    def __enter__(self):
        return self.session

    def __exit__(self, exc_type, exc_value, exc_traceback):
        if exc_value:
            self.session.expunge(self.entity)
            return False
        self.session.commit()
        return True
Example #3
0
def delete(streamsets: StreamSets):
    Session.delete(streamsets)
    Session.commit()
Example #4
0
def save(streamsets: StreamSets):
    if not Session.object_session(streamsets):
        Session.add(streamsets)
    Session.commit()
Example #5
0
def save(source_: Source):
    if not Session.object_session(source_):
        Session.add(source_)
    Session.commit()
Example #6
0
def delete_auth_token(token: AuthenticationToken):
    Session.delete(token)
    Session.commit()
Example #7
0
def save_auth_token(token: AuthenticationToken):
    if not Session.object_session(token):
        Session.add(token)
    Session.commit()
Example #8
0
def delete():
    if not exists():
        return
    Session.delete(get())
    Session.commit()
Example #9
0
def save(destination_: HttpDestination):
    if not Session.object_session(destination_):
        Session.add(destination_)
    Session.commit()
Example #10
0
def remove_deleted_pipeline_id(pipeline_id: str):
    Session.execute(
        f"DELETE FROM deleted_pipelines WHERE pipeline_id = '{pipeline_id}'")
    Session.commit()
Example #11
0
def add_deleted_pipeline_id(pipeline_id: str):
    Session.execute(
        f"INSERT INTO deleted_pipelines VALUES ('{pipeline_id}') ON CONFLICT DO NOTHING"
    )
    Session.commit()
Example #12
0
def delete_offset(pipeline_offset: PipelineOffset):
    Session.delete(pipeline_offset)
    Session.commit()
Example #13
0
def delete(pipeline_: Pipeline):
    Session.delete(pipeline_)
    Session.commit()
Example #14
0
def save(entity: Entity):
    if not Session.object_session(entity):
        Session.add(entity)
    Session.commit()
Example #15
0
def delete_pipeline_retries(pipeline_retries: PipelineRetries):
    Session.delete(pipeline_retries)
    Session.commit()