Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Airflow
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Margrenzo Gunawan
Airflow
Commits
c348553c
Commit
c348553c
authored
Jan 23, 2024
by
Timothy Ardha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Menambahkan function zip file
parent
6b6903e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
1_mgate.py
1_mgate.py
+13
-1
No files found.
1_mgate.py
View file @
c348553c
import
json
,
os
import
shutil
from
datetime
import
date
import
calendar
...
...
@@ -24,6 +25,7 @@ from airflow import XComArg
yesterday_nodash
=
(
datetime
.
now
()
-
timedelta
(
1
)).
strftime
(
'%Y%m%d'
)
if
Variable
.
get
(
"DATE_OF_DATA"
)
==
'today'
else
Variable
.
get
(
"DATE_OF_DATA"
)
yesterday_strip
=
datetime
.
strptime
(
yesterday_nodash
,
'%Y%m%d'
).
strftime
(
'%Y-%m-%d'
)
yesterday_lusa
=
(
datetime
.
strptime
(
yesterday_nodash
,
'%Y%m%d'
)
-
timedelta
(
1
))
d
=
f"""
{
datetime
.
now
().
strftime
(
'%Y-%m-%d %H:%M:%S'
)
}
"""
today
=
d
[:]
...
...
@@ -135,6 +137,11 @@ def pg_push_csv(ti, copy_sql, file_id):
f"""
{
yesterday_nodash
}
/
{
yesterday_nodash
}
."""
if
Variable
.
get
(
"WITH_DATE"
)
==
'Y'
else
''
)
+
f"""
{
file_id
}
.csv"""
)
def
to_zip
():
path_folder
=
f"
{
Variable
.
get
(
"LOCAL_PATH"
)
}{
yesterday_lusa
}
"
shutil
.
make_archive
(
path_folder
,
'zip'
,
path_folder
)
shutil
.
rmtree
(
path_folder
)
with
DAG
(
"APJ_1_mgate"
,
start_date
=
datetime
(
2021
,
1
,
1
),
schedule_interval
=
'10 0 * * *'
,
...
...
@@ -266,7 +273,12 @@ with DAG("APJ_1_mgate",
task_id
=
"history_finish"
,
postgres_conn_id
=
POSTGRES_CONN_ID
,
)
to_zip
=
PythonOperator
(
task_id
=
'to_zip'
,
python_callable
=
to_zip
)
begin
>>
check_done_ext
>>
history_start
>>
create_folder
>>
ds_list_extractor
>>
ds_get_syntax
>>
ds_table_to_csv
>>
ds_get_ddl
>>
pg_drop_schema
>>
pg_create_schema
>>
pg_ddl_syntax
>>
pg_create_table
>>
pg_push_syntax
>>
pg_csv_to_table
>>
set_access_schemma
>>
set_access_all_table
>>
ds_ext_done
>>
history_finish
\ No newline at end of file
begin
>>
check_done_ext
>>
history_start
>>
create_folder
>>
ds_list_extractor
>>
ds_get_syntax
>>
ds_table_to_csv
>>
ds_get_ddl
>>
pg_drop_schema
>>
pg_create_schema
>>
pg_ddl_syntax
>>
pg_create_table
>>
pg_push_syntax
>>
pg_csv_to_table
>>
set_access_schemma
>>
set_access_all_table
>>
ds_ext_done
>>
history_finish
>>
to_zip
\ No newline at end of file
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