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:
final_updated_dict = dict(zip(file_name_list,file_status_list))
for key, value in final_updated_dict.items():
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()
return True
elif value == 'Success' or value == 'Skipped':
status = 'Skipped'
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()
else:
return False
...
...
@@ -198,7 +198,7 @@ class AzureBlobDownloader:
current_date = filename_new
final_name = final_file_name+'_'+current_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:
download_file_path = os.path.join(LOCAL_BLOB_PATH, job_id, file_name)
os.makedirs(os.path.dirname(download_file_path), exist_ok=True)
...
...
@@ -209,7 +209,7 @@ class AzureBlobDownloader:
except Exception as e:
logging.error(e)
def check_audit_postgres(self, d
ate_ts
, filename):
def check_audit_postgres(self, d
t
, filename):
try:
conn = psycopg2.connect(
host=postgre_host,
...
...
@@ -222,7 +222,7 @@ class AzureBlobDownloader:
cur.execute("SELECT start_date, filename from audit_data_table")
row = cur.fetchall()
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()
logging.info("Record Inserted Successfully")
return True
...
...
@@ -233,7 +233,7 @@ class AzureBlobDownloader:
for records in row:
column_list.append(records[0])
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()
logging.info("Record Inserted Successfully")
return True
...
...
@@ -249,12 +249,12 @@ class AzureBlobDownloader:
for key, value in final_updated_dict.items():
if key == filename:
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()
return True
elif value == 'Success' or value == '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()
else:
return False
...
...
@@ -285,3 +285,4 @@ if start_date != '' and end_date != '':
else:
azure_blob_file_downloader = AzureBlobDownloader()
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