forked from evandiewald/helium-transaction-etl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetl.py
31 lines (23 loc) · 888 Bytes
/
etl.py
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
from follower import Follower
import argparse
from models.migrations import Base
from models.migrations import detailed_receipts_sql
from sqlalchemy.engine import create_engine
import os
from dotenv import load_dotenv
if __name__ == "__main__":
load_dotenv()
parser = argparse.ArgumentParser()
parser.add_argument("--migrate", action="store_true", help="Creates tables if they do not already exist.")
parser.add_argument("--start", action="store_true", help="Starts the ETL.")
args = parser.parse_args()
if args.migrate:
print("Running migrations...")
engine = create_engine(os.getenv("POSTGRES_CONNECTION_STR"))
Base.metadata.create_all(engine)
with engine.connect() as con:
res = con.execute(detailed_receipts_sql)
print("done.")
if args.start:
follower = Follower()
follower.run()