-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathETL_DIM_USER.py
More file actions
57 lines (44 loc) · 1.32 KB
/
ETL_DIM_USER.py
File metadata and controls
57 lines (44 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import sys
import keyring as kr;
from ConexaoBD import *;
from DataPipeline import *;
#--------------------- VARIABLES ----------------------------------
params_mysql = {
'user': 'Amanda',
'password':kr.get_password('MYSQL','Amanda')
}
params_ora_p = {
'user': 'Amanda',
'password':kr.get_password('Oracle', 'Amanda')
}
query = """
SELECT
id,
login,
title,
first_name,
last_name,
NOW() as DATA_INCLUSAO
FROM users
WHERE valid_id = 1
"""
columns = ['ID', 'LOGIN', 'TITLE','FIRST_NAME', 'LAST_NAME','DATA_INCLUSAO']
#------------ PIPELINE ---------------
try:
# ------ Conexão MySQL e Oracle ------
mysql_connector = DBConnectorFactory.get_connector('mysql', **params_mysql)
oracle_connector = DBConnectorFactory.get_connector('oracle_prod',**params_ora_p)
# ----------------- Extract e Load ---------------------
elt = ETLProcessor(mysql_connector,oracle_connector)
elt.truncate_table("DIMENSAO_USER")
elt.transfer_data_batch(
source_query=query,
target_table="DIMENSAO_USER",
target_columns=columns
)
elt.close_cursor()
print('elt completed')
except BaseException as error:
print(error)
print(traceback.format_exc())