cli data ingest
This commit is contained in:
@@ -38,7 +38,6 @@ def upgrade() -> None:
|
||||
sa.Column('date_book', sa.Date(), nullable=True),
|
||||
sa.Column('amount', sa.Numeric(precision=12, scale=2), nullable=False),
|
||||
sa.Column('amount_currency', sa.String(length=3), nullable=False),
|
||||
sa.Column('sign', sa.Integer(), nullable=False),
|
||||
sa.Column('reference', sa.String(), nullable=True),
|
||||
sa.Column('other_name', sa.String(), nullable=True),
|
||||
sa.Column('other_iban', sa.String(), nullable=True),
|
||||
|
||||
+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()
|
||||
|
||||
@@ -46,7 +46,6 @@ class B4wDb(BaseModelDb):
|
||||
date_book = Column(Date, nullable=True)
|
||||
amount = Column(Numeric(12, 2), nullable=False)
|
||||
amount_currency = Column(String(3), nullable=False)
|
||||
sign = Column(Integer, nullable=False)
|
||||
reference = Column(String, nullable=True)
|
||||
other_name = Column(String, nullable=True)
|
||||
other_iban = Column(String, nullable=True)
|
||||
|
||||
Reference in New Issue
Block a user