schema_sentinel.metadata_manager.model.schema API documentation

# schema_sentinel.metadata_manager.model.schema

View Source

     1import json
     2
     3import sqlalchemy as db
     4from sqlalchemy import ForeignKey, select
     5
     6from . import CommonBase
     7
     8
     9class Schema(CommonBase):
    10    __tablename__ = "schemas"
    11    database_id = db.Column(db.String, ForeignKey("databases.database_id"), primary_key=True)
    12    schema_id = db.Column(db.String, primary_key=True)
    13    schema_name = db.Column(db.String, primary_key=True)
    14
    15    schema_owner = db.Column(db.String)
    16    is_transient = db.Column(db.String, default="NO")
    17    comment = db.Column(db.String)
    18    created = db.Column(db.String)
    19    last_altered = db.Column(db.String)
    20    retention_time = db.Column(db.Integer)
    21
    22    def save(self, session) -> None:
    23        if not session.execute(self.exists()).first():
    24            session.add(self)
    25            session.commit()
    26
    27    def exists(self) -> str:
    28        return select(Schema).filter_by(schema_id=self.__get_id__())
    29
    30    def __get_id__(self) -> str:
    31        id = json.loads(self.database_id)
    32        id["schema_name"] = self.schema_name
    33        return json.dumps(id)

class Schema(schema_sentinel.metadata_manager.model.CommonBase): View Source

    10class Schema(CommonBase):
    11    __tablename__ = "schemas"
    12    database_id = db.Column(db.String, ForeignKey("databases.database_id"), primary_key=True)
    13    schema_id = db.Column(db.String, primary_key=True)
    14    schema_name = db.Column(db.String, primary_key=True)
    15
    16    schema_owner = db.Column(db.String)
    17    is_transient = db.Column(db.String, default="NO")
    18    comment = db.Column(db.String)
    19    created = db.Column(db.String)
    20    last_altered = db.Column(db.String)
    21    retention_time = db.Column(db.Integer)
    22
    23    def save(self, session) -> None:
    24        if not session.execute(self.exists()).first():
    25            session.add(self)
    26            session.commit()
    27
    28    def exists(self) -> str:
    29        return select(Schema).filter_by(schema_id=self.__get_id__())
    30
    31    def __get_id__(self) -> str:
    32        id = json.loads(self.database_id)
    33        id["schema_name"] = self.schema_name
    34        return json.dumps(id)

The base class of the class hierarchy.

When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.

Schema(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in `kwargs`.

Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.

database_id
schema_id
schema_name
schema_owner
is_transient
comment
created
last_altered
retention_time
def save(self, session) -> None: View Source

    23    def save(self, session) -> None:
    24        if not session.execute(self.exists()).first():
    25            session.add(self)
    26            session.commit()

def exists(self) -> str: View Source

    28    def exists(self) -> str:
    29        return select(Schema).filter_by(schema_id=self.__get_id__())