def __init__(self, dbconn=None): """Initialize the various DbObjectDict-derived dictionaries :param dbconn: a DbConnection object """ self.schemas = SchemaDict(dbconn) self.extensions = ExtensionDict(dbconn) self.languages = LanguageDict(dbconn) self.casts = CastDict(dbconn) self.types = TypeDict(dbconn) self.tables = ClassDict(dbconn) self.columns = ColumnDict(dbconn) self.constraints = ConstraintDict(dbconn) self.indexes = IndexDict(dbconn) self.functions = ProcDict(dbconn) self.operators = OperatorDict(dbconn) self.operclasses = OperatorClassDict(dbconn) self.operfams = OperatorFamilyDict(dbconn) self.rules = RuleDict(dbconn) self.triggers = TriggerDict(dbconn) self.conversions = ConversionDict(dbconn) self.tstempls = TSTemplateDict(dbconn) self.tsdicts = TSDictionaryDict(dbconn) self.tsparsers = TSParserDict(dbconn) self.tsconfigs = TSConfigurationDict(dbconn) self.fdwrappers = ForeignDataWrapperDict(dbconn) self.servers = ForeignServerDict(dbconn) self.usermaps = UserMappingDict(dbconn) self.ftables = ForeignTableDict(dbconn) self.collations = CollationDict(dbconn) self.eventtrigs = EventTriggerDict(dbconn)
def _trim_objects(self, schemas): """Remove unwanted schema objects :param schemas: list of schemas to keep """ for objtype in ['types', 'tables', 'constraints', 'indexes', 'functions', 'operators', 'operclasses', 'operfams', 'rules', 'triggers', 'conversions', 'tstempls', 'tsdicts', 'tsparsers', 'tsconfigs', 'extensions', 'collations', 'eventtrigs']: objdict = getattr(self.db, objtype) for obj in list(objdict.keys()): # obj[0] is the schema name in all these dicts if obj[0] not in schemas: del objdict[obj] for sch in list(self.db.schemas.keys()): if sch not in schemas: del self.db.schemas[sch] # exclude database-wide objects self.db.languages = LanguageDict() self.db.casts = CastDict()
def __init__(self, dbconn=None, single_db=False): """Initialize the various DbObjectDict-derived dictionaries :param dbconn: a DbConnection object """ self.schemas = SchemaDict(dbconn) self.extensions = ExtensionDict(dbconn) self.languages = LanguageDict(dbconn) self.casts = CastDict(dbconn) self.types = TypeDict(dbconn) self.tables = ClassDict(dbconn) self.columns = ColumnDict(dbconn) self.constraints = ConstraintDict(dbconn) self.indexes = IndexDict(dbconn) self.functions = ProcDict(dbconn) self.operators = OperatorDict(dbconn) self.operclasses = OperatorClassDict(dbconn) self.operfams = OperatorFamilyDict(dbconn) self.rules = RuleDict(dbconn) self.triggers = TriggerDict(dbconn) self.conversions = ConversionDict(dbconn) self.tstempls = TSTemplateDict(dbconn) self.tsdicts = TSDictionaryDict(dbconn) self.tsparsers = TSParserDict(dbconn) self.tsconfigs = TSConfigurationDict(dbconn) self.fdwrappers = ForeignDataWrapperDict(dbconn) self.servers = ForeignServerDict(dbconn) self.usermaps = UserMappingDict(dbconn) self.ftables = ForeignTableDict(dbconn) self.collations = CollationDict(dbconn) self.eventtrigs = EventTriggerDict(dbconn) # Populate a map from system catalog to the respective dict self._catalog_map = {} for _, d in self.all_dicts(single_db): if d.cls.catalog is not None: self._catalog_map[d.cls.catalog] = d # Map from objects extkey to their (dict name, key) self._extkey_map = {}