cli data ingest
This commit is contained in:
+11
-7
@@ -4,6 +4,16 @@ import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from src.reader import reader_b4w, reader_raw
|
||||
from src.helper_db import upsert_b4w
|
||||
from src.db import get_session
|
||||
|
||||
|
||||
def ingest_b4w(path: Path):
|
||||
data = reader_b4w(path)
|
||||
with get_session() as session:
|
||||
for row in data:
|
||||
upsert_b4w(session, row, do_commit=False)
|
||||
session.commit()
|
||||
|
||||
|
||||
def main():
|
||||
@@ -15,13 +25,7 @@ def main():
|
||||
|
||||
path = Path(args.input)
|
||||
|
||||
data_raw = reader_raw(path)
|
||||
|
||||
print(data_raw[:10])
|
||||
|
||||
data = reader_b4w(path)
|
||||
print(data[:10])
|
||||
|
||||
ingest_b4w(path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user