-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathetl.py
More file actions
33 lines (23 loc) · 665 Bytes
/
etl.py
File metadata and controls
33 lines (23 loc) · 665 Bytes
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
# %%
import pandas as pd
import sqlalchemy
# conexão cm banco
engine = sqlalchemy.create_engine("sqlite:///database.db")
# lendo a query do arquivo de texto
with open("etl_projeto.sql") as open_file:
query = open_file.read()
# %%
dates = [
'2025-01-01',
'2025-02-01',
'2025-03-01',
'2025-04-01',
'2025-05-01',
'2025-06-01',
'2025-07-01',
]
for i in dates:
# EXECUTA A QUERY E TRAZ OS DADOS PARA O PYTHON
df = pd.read_sql(query.format(date=i), engine)
# PEGA OS DADOS DO PYTHON E MANDA PARA O BANCO NA TABELA feature_store_cliente
df.to_sql("feature_store_cliente", engine, index=False, if_exists="append")