schema_sentinel.metadata_manager.model.view API documentation

# schema_sentinel.metadata_manager.model.view

View Source

     1import json
     2
     3import sqlalchemy as db
     4from sqlalchemy import ForeignKey, select
     5
     6from . import CommonBase
     7
     8
     9class View(CommonBase):
    10    __tablename__ = "views"
    11    view_id = db.Column(db.String, primary_key=True)
    12    schema_id = db.Column(db.String, ForeignKey("schemas.schema_id"))
    13    view_name = db.Column(db.String)
    14    view_owner = db.Column(db.String)
    15    view_definition = db.Column(db.String)
    16    is_secure = db.Column(db.String)
    17    is_materialized = db.Column(db.String)
    18    change_tracking = db.Column(db.String)
    19    created = db.Column(db.String)
    20    enable_schema_evolution = db.Column(db.String)
    21    owner_role_type = db.Column(db.String)
    22    comment = db.Column(db.String)
    23
    24    def save(self, session) -> None:
    25        if not session.execute(self.exists()).first():
    26            session.add(self)
    27            session.commit()
    28
    29    def exists(self) -> str:
    30        return select(View).filter_by(view_id=self.view_id)
    31
    32    def __get_id__(self) -> str:
    33        id = json.loads(self.schema_id)
    34        id["view_name"] = self.view_name
    35        return json.dumps(id)

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

    10class View(CommonBase):
    11    __tablename__ = "views"
    12    view_id = db.Column(db.String, primary_key=True)
    13    schema_id = db.Column(db.String, ForeignKey("schemas.schema_id"))
    14    view_name = db.Column(db.String)
    15    view_owner = db.Column(db.String)
    16    view_definition = db.Column(db.String)
    17    is_secure = db.Column(db.String)
    18    is_materialized = db.Column(db.String)
    19    change_tracking = db.Column(db.String)
    20    created = db.Column(db.String)
    21    enable_schema_evolution = db.Column(db.String)
    22    owner_role_type = db.Column(db.String)
    23    comment = db.Column(db.String)
    24
    25    def save(self, session) -> None:
    26        if not session.execute(self.exists()).first():
    27            session.add(self)
    28            session.commit()
    29
    30    def exists(self) -> str:
    31        return select(View).filter_by(view_id=self.view_id)
    32
    33    def __get_id__(self) -> str:
    34        id = json.loads(self.schema_id)
    35        id["view_name"] = self.view_name
    36        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.

View(**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.

view_id
schema_id
view_name
view_owner
view_definition
is_secure
is_materialized
change_tracking
created
enable_schema_evolution
owner_role_type
comment
def save(self, session) -> None: View Source

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

def exists(self) -> str: View Source

    30    def exists(self) -> str:
    31        return select(View).filter_by(view_id=self.view_id)