session maker updated
This commit is contained in:
parent
f3b053af78
commit
a256d9d70c
|
|
@ -18,7 +18,7 @@ def collect_parsed_data_from_mongo_database(mongo_provider) -> list:
|
||||||
def write_parsed_data_to_account_records(
|
def write_parsed_data_to_account_records(
|
||||||
file: str, data_dict: dict, collection_name: str, mongo_provider
|
file: str, data_dict: dict, collection_name: str, mongo_provider
|
||||||
):
|
):
|
||||||
db_session = AccountRecords.new_session()
|
with AccountRecords.new_session() as db_session:
|
||||||
data_dict["bank_balance"] = data_dict.pop("balance")
|
data_dict["bank_balance"] = data_dict.pop("balance")
|
||||||
data_dict["import_file_name"] = collection_name
|
data_dict["import_file_name"] = collection_name
|
||||||
data_dict = BankReceive(**data_dict).model_dump()
|
data_dict = BankReceive(**data_dict).model_dump()
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,9 @@ class BaseAlchemyModel:
|
||||||
__abstract__ = True
|
__abstract__ = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new_session(cls) -> Session:
|
def new_session(cls):
|
||||||
"""Get database session."""
|
"""Get database session."""
|
||||||
|
return get_db()
|
||||||
with get_db() as session:
|
|
||||||
return session
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def flush(cls: Type[T], db: Session) -> T:
|
def flush(cls: Type[T], db: Session) -> T:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue