Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BAAN Data
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vamsikrishna.vemulamanda
BAAN Data
Commits
79475277
Commit
79475277
authored
Jul 06, 2021
by
vamsikrishna.vemulamanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update read_azure_data
parent
a10ff04f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
read_data_azure/read_azure_data
read_data_azure/read_azure_data
+9
-8
No files found.
read_data_azure/read_azure_data
View file @
79475277
...
@@ -146,13 +146,13 @@ class AzureBlobDownloaderHistorical:
...
@@ -146,13 +146,13 @@ class AzureBlobDownloaderHistorical:
final_updated_dict = dict(zip(file_name_list,file_status_list))
final_updated_dict = dict(zip(file_name_list,file_status_list))
for key, value in final_updated_dict.items():
for key, value in final_updated_dict.items():
if value != 'Success' or value != 'Skipped':
if value != 'Success' or value != 'Skipped':
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)',(d
ate_ts
, filename))
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)',(d
t
, filename))
conn.commit()
conn.commit()
return True
return True
elif value == 'Success' or value == 'Skipped':
elif value == 'Success' or value == 'Skipped':
status = 'Skipped'
status = 'Skipped'
cur.execute('insert into audit_data_table(start_date, filename, status) values(%s, %s, %s)',
cur.execute('insert into audit_data_table(start_date, filename, status) values(%s, %s, %s)',
(d
ate_ts
, filename, status))
(d
t
, filename, status))
conn.commit()
conn.commit()
else:
else:
return False
return False
...
@@ -198,7 +198,7 @@ class AzureBlobDownloader:
...
@@ -198,7 +198,7 @@ class AzureBlobDownloader:
current_date = filename_new
current_date = filename_new
final_name = final_file_name+'_'+current_date
final_name = final_file_name+'_'+current_date
if current_date == today_date:
if current_date == today_date:
validate_postgres = self.check_audit_postgres(d
ate_ts
, final_name)
validate_postgres = self.check_audit_postgres(d
t
, final_name)
if validate_postgres:
if validate_postgres:
download_file_path = os.path.join(LOCAL_BLOB_PATH, job_id, file_name)
download_file_path = os.path.join(LOCAL_BLOB_PATH, job_id, file_name)
os.makedirs(os.path.dirname(download_file_path), exist_ok=True)
os.makedirs(os.path.dirname(download_file_path), exist_ok=True)
...
@@ -209,7 +209,7 @@ class AzureBlobDownloader:
...
@@ -209,7 +209,7 @@ class AzureBlobDownloader:
except Exception as e:
except Exception as e:
logging.error(e)
logging.error(e)
def check_audit_postgres(self, d
ate_ts
, filename):
def check_audit_postgres(self, d
t
, filename):
try:
try:
conn = psycopg2.connect(
conn = psycopg2.connect(
host=postgre_host,
host=postgre_host,
...
@@ -222,7 +222,7 @@ class AzureBlobDownloader:
...
@@ -222,7 +222,7 @@ class AzureBlobDownloader:
cur.execute("SELECT start_date, filename from audit_data_table")
cur.execute("SELECT start_date, filename from audit_data_table")
row = cur.fetchall()
row = cur.fetchall()
if not row:
if not row:
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)', (d
ate_ts
, filename))
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)', (d
t
, filename))
conn.commit()
conn.commit()
logging.info("Record Inserted Successfully")
logging.info("Record Inserted Successfully")
return True
return True
...
@@ -233,7 +233,7 @@ class AzureBlobDownloader:
...
@@ -233,7 +233,7 @@ class AzureBlobDownloader:
for records in row:
for records in row:
column_list.append(records[0])
column_list.append(records[0])
if filename not in column_list:
if filename not in column_list:
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)', (d
ate_ts
, filename))
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)', (d
t
, filename))
conn.commit()
conn.commit()
logging.info("Record Inserted Successfully")
logging.info("Record Inserted Successfully")
return True
return True
...
@@ -249,12 +249,12 @@ class AzureBlobDownloader:
...
@@ -249,12 +249,12 @@ class AzureBlobDownloader:
for key, value in final_updated_dict.items():
for key, value in final_updated_dict.items():
if key == filename:
if key == filename:
if value != 'Success' and value != 'Skipped':
if value != 'Success' and value != 'Skipped':
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)',(d
ate_ts
, filename))
cur.execute('insert into audit_data_table(start_date, filename) values(%s, %s)',(d
t
, filename))
conn.commit()
conn.commit()
return True
return True
elif value == 'Success' or value == 'Skipped':
elif value == 'Success' or value == 'Skipped':
status = 'Skipped'
status = 'Skipped'
cur.execute('insert into audit_data_table(start_date, filename, status) values(%s, %s, %s)',(d
ate_ts
, filename, status))
cur.execute('insert into audit_data_table(start_date, filename, status) values(%s, %s, %s)',(d
t
, filename, status))
conn.commit()
conn.commit()
else:
else:
return False
return False
...
@@ -285,3 +285,4 @@ if start_date != '' and end_date != '':
...
@@ -285,3 +285,4 @@ if start_date != '' and end_date != '':
else:
else:
azure_blob_file_downloader = AzureBlobDownloader()
azure_blob_file_downloader = AzureBlobDownloader()
azure_blob_file_downloader.download_all_blobs_in_container()
azure_blob_file_downloader.download_all_blobs_in_container()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment