I am creating a python project using SQLite with SQLAlchemy and attempting to set up async, but am running into this error:

```
2024-07-05 21:25:42,680 - ERROR - An error occurred while processing G:\_AI\training data\Concepts\Stealth Sex\Other Room\Photo\d66c96a9b54b4ccbf4909bee3bf68bfb.jpeg: This session is provisioning a new connection; concurrent operations are not permitted (Background on this error at: https://sqlalche.me/e/20/isce)
Traceback (most recent call last):
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\app.py", line 91, in register_file
    db_file = await crud.create_file(db, filepath, mime_type, file_size, creation_time, modification_time)
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\database\crud.py", line 95, in create_file
    result = await db.execute(
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\ext\asyncio\session.py", line 461, in execute
    result = await greenlet_spawn(
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 190, in greenlet_spawn
    result = context.switch(*args, **kwargs)
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 2351, in execute
    return self._execute_internal(
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 2226, in _execute_internal
    conn = self._connection_for_bind(bind)
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 2095, in _connection_for_bind
    return trans._connection_for_bind(engine, execution_options)
  File "<string>", line 2, in _connection_for_bind
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\state_changes.py", line 103, in _go
    self._raise_for_prerequisite_state(fn.__name__, current_state)
  File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 990, in _raise_for_prerequisite_state
    raise sa_exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: This session is provisioning a new connection; concurrent operations are not permitted (Background on this error at: https://sqlalche.me/e/20/isce)
```

The function create_file in my database\crud.py that the error points to on line 95 is this:
```
async def create_file(db: AsyncSession, path: str, file_type: str, size: int, file_created_at: DateTime, file_updated_at: DateTime):
    """
    Creates a new file record in the database.
    
    Parameters:
        db (Session): The database session.
        path (str): The file path.
        file_type (str): The type of the file.
        size (int): The size of the file in bytes.
        file_created_at (datetime): When the file was created.
        file_updated_at (datetime): When the file was last updated.

    Returns:
        File: The created File object.
    """
    # Check if the entry already exists in the database
    result = await db.execute(
        select(File).where(File.path == path)
    )

    db_file = result.scalars().first()

    if db_file:
        return db_file

    new_file = File(
        path=path,
        type=file_type,
        size=size,
        file_created_at=file_created_at,
        file_updated_at=file_updated_at
    )

    db.add(new_file)
    await db.commit()
    await db.refresh(new_file)

    return new_file
```

And above that, the register_file in my app.py is:
```
async def register_file(filepath: str, db: AsyncSession):
    """
    Processes each file for registration by storing its metadata and fingerprint in the database.

    Args:
    filepath (str): The full path to the file.
    db (AsyncSession): An instance of the database session.
    """
    try:
        file_size = os.path.getsize(filepath)
        mime_type = guess_mime_type(filepath)
        creation_time = datetime.fromtimestamp(os.path.getctime(filepath))
        modification_time = datetime.fromtimestamp(os.path.getmtime(filepath))

        # Create or get the file entry
        db_file = await crud.create_file(db, filepath, mime_type, file_size, creation_time, modification_time)

        # Hashing the file
        file_hash = get_file_hash(filepath)

        # Update or create fingerprint
        await crud.update_or_create_fingerprint(db, db_file.id, file_hash, file_size)

        logger.info(f"Processed file successfully: {filepath}")

    except FileNotFoundError:
        logger.error(f"File not found: {filepath}")
    except PermissionError:
        logger.error(f"Permission denied for file: {filepath}")
    except Exception as e:
        logger.exception(f"An error occurred while processing {filepath}: {e}")
```

Please analyse and provide detailed feedback, information and suggestions, and if you need other parts of the code for extra context ask and I will provide so that we can fix all the async issues when dealing with database transactions in SQLite using SQLAlchemy.