Fixes to the sqlalchemy adapter
This commit is contained in:
parent
7d3e124e4f
commit
b5a3b69e49
2 changed files with 7 additions and 3 deletions
|
|
@ -119,7 +119,7 @@ async def cognify(datasets: Union[str, list[str]] = None, user: User = None):
|
|||
dataset_name = generate_dataset_name(dataset)
|
||||
|
||||
if dataset_name in existing_datasets:
|
||||
awaitables.append(run_cognify_pipeline(dataset, db_engine.get_files_metadata(dataset_name)))
|
||||
awaitables.append(run_cognify_pipeline(dataset, await db_engine.get_files_metadata(dataset_name)))
|
||||
|
||||
return await asyncio.gather(*awaitables)
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,12 @@ class SQLAlchemyAdapter():
|
|||
|
||||
async def get_files_metadata(self, dataset_name: str):
|
||||
async with self.engine.connect() as connection:
|
||||
result = await connection.execute(text(f"SELECT id, name, file_path, extension, mime_type FROM {dataset_name}.file_metadata;"))
|
||||
return [dict(row) for row in result]
|
||||
result = await connection.execute(
|
||||
text(f"SELECT id, name, file_path, extension, mime_type FROM {dataset_name}.file_metadata;"))
|
||||
rows = result.fetchall()
|
||||
metadata = [{"id": row.id, "name": row.name, "file_path": row.file_path, "extension": row.extension,
|
||||
"mime_type": row.mime_type} for row in rows]
|
||||
return metadata
|
||||
|
||||
async def delete_table(self, table_name: str):
|
||||
async with self.engine.connect() as connection:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue