Fixed the csv_import

This commit is contained in:
Jonas Linter
2025-11-18 18:37:30 +01:00
parent 0633718604
commit e5abefe690
2 changed files with 7 additions and 4 deletions

View File

@@ -1161,13 +1161,16 @@ async def _process_csv_import_background(
_LOGGER.info("Starting database processing of %s", filename)
# Create a new session for this background task
async with session_maker() as db_session:
db_session = await session_maker.create_session()
try:
importer = CSVImporter(db_session, config)
stats = await importer.import_csv_file(str(log_filename), hotel_code, dryrun=False)
_LOGGER.info(
"CSV import complete for %s: %s", filename, stats
)
finally:
await db_session.close()
except Exception:
_LOGGER.exception(
"Error processing CSV import in background for %s", filename