Commit 12499eed authored by Erly Villaroel's avatar Erly Villaroel

Cambios Verificacion de tablas antes de la creacion

parent c81e2e09
...@@ -113,7 +113,7 @@ class Oracle: ...@@ -113,7 +113,7 @@ class Oracle:
def check_procedure(self, procedure_name, connection) -> bool: def check_procedure(self, procedure_name, connection) -> bool:
exists = False exists = False
try: try:
check_query = f"SHOW CREATE PROCEDURE {procedure_name}" check_query = f"SELECT text FROM all_source WHERE name = '{procedure_name}'"
result = connection.execute(check_query) result = connection.execute(check_query)
exists = bool(result.fetchone()) exists = bool(result.fetchone())
except Exception as e: except Exception as e:
...@@ -124,7 +124,7 @@ class Oracle: ...@@ -124,7 +124,7 @@ class Oracle:
def check_table(self, table_name, connection) -> bool: def check_table(self, table_name, connection) -> bool:
exists = False exists = False
try: try:
check_query = f"SHOW CREATE TABLE {table_name}" check_query = f"DESCRIBE {table_name}"
result = connection.execute(check_query) result = connection.execute(check_query)
exists = bool(result.fetchone()) exists = bool(result.fetchone())
except Exception as e: except Exception as e:
......
...@@ -107,7 +107,7 @@ class Postgres: ...@@ -107,7 +107,7 @@ class Postgres:
def check_procedure(self, procedure_name, connection) -> bool: def check_procedure(self, procedure_name, connection) -> bool:
exists = False exists = False
try: try:
check_query = f"SHOW CREATE PROCEDURE {procedure_name}" check_query = f"SELECT pg_get_functiondef('{procedure_name}')"
result = connection.execute(check_query) result = connection.execute(check_query)
exists = bool(result.fetchone()) exists = bool(result.fetchone())
except Exception as e: except Exception as e:
...@@ -118,7 +118,7 @@ class Postgres: ...@@ -118,7 +118,7 @@ class Postgres:
def check_table(self, table_name, connection) -> bool: def check_table(self, table_name, connection) -> bool:
exists = False exists = False
try: try:
check_query = f"SHOW CREATE TABLE {table_name}" check_query = f"SELECT pg_get_tabledef('{table_name}')"
result = connection.execute(check_query) result = connection.execute(check_query)
exists = bool(result.fetchone()) exists = bool(result.fetchone())
except Exception as e: except Exception as e:
......
...@@ -150,6 +150,7 @@ def extract_from_source(command, source_conn, intern_conn, chunksize: int, timez ...@@ -150,6 +150,7 @@ def extract_from_source(command, source_conn, intern_conn, chunksize: int, timez
else: else:
raise AssertionError(f"Error creando tabla {tablename}") raise AssertionError(f"Error creando tabla {tablename}")
if is_procedure: if is_procedure:
logger.info(f"procedure: {tablename}")
command = command[len(tablename+"|"):] command = command[len(tablename+"|"):]
temp_connection = source_conn.get_basic_connection() temp_connection = source_conn.get_basic_connection()
command = source_conn.generate_sql_procedure(command) command = source_conn.generate_sql_procedure(command)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment