Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TypeError from sa.create_engine with pool_size on SQLiteΒ #3351

@z0u

Description

@z0u

πŸ› Bug

When running aim up, a TypeError is raised from SQLAlchemy's create_engine. This happens because pool_size and max_overflow arguments are passed to create_engine for an SQLite database, which defaults to using NullPool and does not accept these arguments.

This issue appears to have been introduced in a version after 3.27.0, as that version did not specify these pooling arguments.

The error is present in both aim/web/api/db.py and aim/storage/structured/db.py.

TypeError: Invalid argument(s) 'pool_size','max_overflow' sent to create_engine(), using configuration SQLiteDialect_pysqlite/NullPool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.

To reproduce

  1. Install Aim ~=3.28.0 or ~=3.29.0.
  2. Run aim init in a directory.
  3. Run aim up.
  4. See the error below.

Expected behavior

The aim up command should start the Aim UI server without raising a TypeError.

Environment

  • Aim 3.28.0, 3.29.1
  • Python 3.12
  • pip 24.3.1
  • sqlalchemy v1.4.13
  • OS Linux (Docker)

Full dependency tree (output from uv tree):

aim v3.29.1
β”œβ”€β”€ aim-ui v3.29.1
β”œβ”€β”€ aimrecords v0.0.7
β”‚   └── base58 v2.0.1
β”œβ”€β”€ aimrocks v0.5.2
β”œβ”€β”€ aiofiles v24.1.0
β”œβ”€β”€ alembic v1.6.0
β”‚   β”œβ”€β”€ mako v1.3.10
β”‚   β”‚   └── markupsafe v3.0.2
β”‚   β”œβ”€β”€ python-dateutil v2.9.0.post0
β”‚   β”‚   └── six v1.17.0
β”‚   β”œβ”€β”€ python-editor v1.0.4
β”‚   └── sqlalchemy v1.4.13
β”‚       └── greenlet v3.2.3
β”œβ”€β”€ boto3 v1.39.3
β”‚   β”œβ”€β”€ botocore v1.39.3
β”‚   β”‚   β”œβ”€β”€ jmespath v1.0.1
β”‚   β”‚   β”œβ”€β”€ python-dateutil v2.9.0.post0
β”‚   β”‚   └── urllib3 v2.4.0
β”‚   β”œβ”€β”€ jmespath v1.0.1
β”‚   └── s3transfer v0.13.0
β”‚       └── botocore v1.39.3
β”œβ”€β”€ cachetools v4.2.4
β”œβ”€β”€ click v8.1.8
β”œβ”€β”€ cryptography v45.0.5
β”‚   └── cffi v1.17.1
β”‚       └── pycparser v2.22
β”œβ”€β”€ fastapi v0.116.0
β”‚   β”œβ”€β”€ pydantic v2.11.5
β”‚   β”‚   β”œβ”€β”€ annotated-types v0.7.0
β”‚   β”‚   β”œβ”€β”€ pydantic-core v2.33.2
β”‚   β”‚   β”‚   └── typing-extensions v4.14.0
β”‚   β”‚   β”œβ”€β”€ typing-extensions v4.14.0
β”‚   β”‚   └── typing-inspection v0.4.1
β”‚   β”‚       └── typing-extensions v4.14.0
β”‚   β”œβ”€β”€ starlette v0.46.2
β”‚   β”‚   └── anyio v4.9.0
β”‚   β”‚       β”œβ”€β”€ idna v3.10
β”‚   β”‚       β”œβ”€β”€ sniffio v1.3.1
β”‚   β”‚       └── typing-extensions v4.14.0
β”‚   └── typing-extensions v4.14.0
β”œβ”€β”€ filelock v3.18.0
β”œβ”€β”€ jinja2 v3.1.6
β”‚   └── markupsafe v3.0.2
β”œβ”€β”€ numpy v2.3.0
β”œβ”€β”€ packaging v25.0
β”œβ”€β”€ pillow v11.2.1
β”œβ”€β”€ psutil v7.0.0
β”œβ”€β”€ python-dateutil v2.9.0.post0
β”œβ”€β”€ pytz v2020.1
β”œβ”€β”€ requests v2.32.3
β”‚   β”œβ”€β”€ certifi v2025.4.26
β”‚   β”œβ”€β”€ charset-normalizer v3.4.2
β”‚   β”œβ”€β”€ idna v3.10
β”‚   └── urllib3 v2.4.0
β”œβ”€β”€ restrictedpython v8.0
β”œβ”€β”€ sqlalchemy v1.4.13
β”œβ”€β”€ tqdm v4.67.1
β”œβ”€β”€ uvicorn v0.35.0
β”‚   β”œβ”€β”€ click v8.1.8
β”‚   └── h11 v0.16.0
β”œβ”€β”€ watchdog v6.0.0
└── websockets v15.0.1

Additional context

A potential fix is to explicitly set a compatible connection pool, like QueuePool, when creating the engine for SQLite, or to remove the pool_size and max_overflow arguments if pooling is not intended for the SQLite connection.

I've tried this and it appears to work:

from sqlalchemy.pool import QueuePool

engine = create_engine(
    get_db_url(),
    # ... other args
    poolclass=QueuePool,  # Explicitly set the pool class
    pool_size=10,
    max_overflow=20,
)

I.e. it starts, but I haven't tested the app thoroughly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions