def Main(): cgiEnv = lib_oracle.OracleEnv() ora_table = cgiEnv.m_entity_id_dict["Table"] ora_schema = cgiEnv.m_entity_id_dict["Schema"] ora_database = cgiEnv.m_entity_id_dict["Db"] grph = cgiEnv.GetGraph() # TYPE = "VIEW", "TABLE", "PACKAGE BODY" etc... sql_query = "select owner,name,type from all_dependencies where REFERENCED_TYPE = 'TABLE' AND REFERENCED_NAME = '" \ + ora_table + "' and referenced_owner='" + ora_schema + "'" logging.debug("sql_query=%s", sql_query) node_ora_table = oracle_table.MakeUri(ora_database, ora_schema, ora_table) node_ora_schema = oracle_schema.MakeUri(ora_database, ora_schema) grph.add((node_ora_schema, pc.property_oracle_table, node_ora_table)) result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query) for row in result: lib_oracle.AddDependency(grph, row, node_ora_table, ora_database, True) cgiEnv.OutCgiRdf("LAYOUT_RECT")
def Main(): cgiEnv = lib_oracle.OracleEnv() oraSchema = cgiEnv.m_entity_id_dict["Schema"] grph = cgiEnv.GetGraph() sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER = '" + oraSchema + "'" sys.stderr.write("sql_query=%s\n" % sql_query) node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema) result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query) for row in result: tableName = str(row[0]) # sys.stderr.write("tableName=%s\n" % tableName ) nodeTable = oracle_table.MakeUri(cgiEnv.m_oraDatabase, oraSchema, tableName) grph.add((node_oraschema, pc.property_oracle_table, nodeTable)) lib_oracle.AddLiteralNotNone(grph, nodeTable, "Status", row[1]) lib_oracle.AddLiteralNotNone(grph, nodeTable, "Creation", row[2]) # It cannot work if there are too many tables. # cgiEnv.OutCgiRdf("LAYOUT_RECT") cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_table])
def Main(): cgiEnv = lib_oracle.OracleEnv() ora_schema = cgiEnv.m_entity_id_dict["Schema"] grph = cgiEnv.GetGraph() sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER = '" + ora_schema + "'" logging.debug("sql_query=%s", sql_query) node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, ora_schema) result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query) for row in result: table_name = str(row[0]) node_table = oracle_table.MakeUri(cgiEnv.m_oraDatabase, ora_schema, table_name) grph.add((node_oraschema, pc.property_oracle_table, node_table)) lib_oracle.AddLiteralNotNone(grph, node_table, "Status", row[1]) lib_oracle.AddLiteralNotNone(grph, node_table, "Creation", row[2]) # "Collapsing", clustering nodes is needed if there are many objects. cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_table])
def QueryToNodesList(connection_kw, list_of_tables, default_schema_name=None): nodes_list = [] # This should be taken from the credentials. if not default_schema_name: default_schema_name = "OracleDefaultSchema" for tab_nam in list_of_tables: splt_tab_nam = tab_nam.split(".") if len(splt_tab_nam) == 2: schema_name = splt_tab_nam[0] table_name_no_schema = splt_tab_nam[1] else: schema_name = default_schema_name table_name_no_schema = tab_nam tmp_node = oracle_table.MakeUri(connection_kw["Db"], schema_name, table_name_no_schema) nodes_list.append(tmp_node) return nodes_list
def AddDependency(grph, row, nodeRoot, oraDatabase, direction): depOwner = str(row[0]) depName = str(row[1]) depType = str(row[2]) if depType == "TABLE": nodeObject = oracle_table.MakeUri(oraDatabase, depOwner, depName) elif depType == "VIEW": nodeObject = oracle_view.MakeUri(oraDatabase, depOwner, depName) elif depType == "PACKAGE": nodeObject = oracle_package.MakeUri(oraDatabase, depOwner, depName) elif depType == "PACKAGE BODY": nodeObject = oracle_package_body.MakeUri(oraDatabase, depOwner, depName) elif depType == "SYNONYM": nodeObject = oracle_synonym.MakeUri(oraDatabase, depOwner, depName) elif depType == "TYPE": nodeObject = oracle_type.MakeUri(oraDatabase, depOwner, depName) elif depType == "SEQUENCE": nodeObject = oracle_sequence.MakeUri(oraDatabase, depOwner, depName) elif depType == "LIBRARY": nodeObject = oracle_library.MakeUri(oraDatabase, depOwner, depName) elif depType == "PROCEDURE": nodeObject = oracle_procedure.MakeUri(oraDatabase, depOwner, depName) elif depType == "FUNCTION": nodeObject = oracle_function.MakeUri(oraDatabase, depOwner, depName) elif depType == "TRIGGER": nodeObject = oracle_trigger.MakeUri(oraDatabase, depOwner, depName) else: lib_common.ErrorMessageHtml( "Unknown dependency depType=%s depName=%s" % (depType, depName)) return if direction == True: grph.add((nodeRoot, pc.property_oracle_depends, nodeObject)) else: grph.add((nodeObject, pc.property_oracle_depends, nodeRoot))