Skip to content

Commit

Permalink
upd steps and db operation for executequery
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucaaccenture committed Sep 23, 2024
1 parent 63ec3d1 commit acf3ced
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,26 @@ def getConnection(host:str, database:str, user:str, password:str, port:str):
# print(f"The error '{e}' occurred")


def executeQuery(conn, query:str, as_dict:bool = False) -> list:
def executeQuery(context, conn, query:str, as_dict:bool = False) -> list:
print(f' Executing query [{query}] on genericQuery service...')
try:
print('executing_sql_query ...')
headers = {'Ocp-Apim-Subscription-Key': '2da21a24a3474673ad8464edb4a71011'}

user_profile = None
try:
user_profile = getattr(context, "user_profile")
print(f"User Profile: {user_profile} ->>> local run!")
except AttributeError as e:
print(f"User Profile None: {e} ->>> remote run!")

####RUN DA LOCALE
if user_profile != None:
SUBKEY = os.getenv('SUBKEY')
####RUN DA REMOTO
else:
SUBKEY = context.config.userdata.get("env").get("SUBKEY")

headers = {'Ocp-Apim-Subscription-Key': SUBKEY}

url = apicfg_testing_support.get("base_path") + apicfg_testing_support.get("service")
print(f">>>>>>>>>>>>>>db operation apicfg URL {url}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def closeConnection(conn) -> None:
traceback.print_exc()


def executeQuery(conn, query:str, as_dict:bool = False) -> list:
def executeQuery(context, conn, query:str, as_dict:bool = False) -> list:
print(f' Executing query [{query}] on OracleDB instance...')
try:
cur = conn.cursor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def getConnection(host:str, database:str, user:str, password:str, port:str):



def execute_read_query(connection, query):
def execute_read_query(context, connection, query):
print(f' Executing query [{query}] on PostgresDB instance...')
cursor = connection.cursor()
result = None
Expand All @@ -77,8 +77,8 @@ def execute_read_query(connection, query):
print(f"The error '{e}' occurred")

# wrapper
def executeQuery(conn, query:str, as_dict:bool = False) -> list:
return execute_read_query(conn, query)
def executeQuery(context, conn, query:str, as_dict:bool = False) -> list:
return execute_read_query(context, conn, query)


def closeConnection_old(conn) -> None:
Expand Down
Loading

0 comments on commit acf3ced

Please sign in to comment.