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('date_book', sa.Date(), nullable=True),
|
||||||
sa.Column('amount', sa.Numeric(precision=12, scale=2), nullable=False),
|
sa.Column('amount', sa.Numeric(precision=12, scale=2), nullable=False),
|
||||||
sa.Column('amount_currency', sa.String(length=3), 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('reference', sa.String(), nullable=True),
|
||||||
sa.Column('other_name', sa.String(), nullable=True),
|
sa.Column('other_name', sa.String(), nullable=True),
|
||||||
sa.Column('other_iban', 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 pathlib import Path
|
||||||
|
|
||||||
from src.reader import reader_b4w, reader_raw
|
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():
|
def main():
|
||||||
@@ -15,13 +25,7 @@ def main():
|
|||||||
|
|
||||||
path = Path(args.input)
|
path = Path(args.input)
|
||||||
|
|
||||||
data_raw = reader_raw(path)
|
ingest_b4w(path)
|
||||||
|
|
||||||
print(data_raw[:10])
|
|
||||||
|
|
||||||
data = reader_b4w(path)
|
|
||||||
print(data[:10])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ class B4wDb(BaseModelDb):
|
|||||||
date_book = Column(Date, nullable=True)
|
date_book = Column(Date, nullable=True)
|
||||||
amount = Column(Numeric(12, 2), nullable=False)
|
amount = Column(Numeric(12, 2), nullable=False)
|
||||||
amount_currency = Column(String(3), nullable=False)
|
amount_currency = Column(String(3), nullable=False)
|
||||||
sign = Column(Integer, nullable=False)
|
|
||||||
reference = Column(String, nullable=True)
|
reference = Column(String, nullable=True)
|
||||||
other_name = Column(String, nullable=True)
|
other_name = Column(String, nullable=True)
|
||||||
other_iban = Column(String, nullable=True)
|
other_iban = Column(String, nullable=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user