Skip to content

Conversation

@donlon
Copy link
Contributor

@donlon donlon commented Dec 13, 2025

Description

After recent changes in aiosqlite 0.22.0 (omnilib/aiosqlite@1cd60ad), calling self._connection.start() results in 'Connection' object has no attribute 'start' exception. Creating connection in this way seems to be a misuse of its API. To fix it, we create connection with await aiosqlite.connect(...) instead of directly calling the internal methods.

Closes #2037

  File "/home/donlon/test.py", line 74, in init_db
    await Tortoise.generate_schemas()
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/__init__.py", line 594, in generate_schemas
    await generate_schema_for_client(connection, safe)
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/utils.py", line 46, in generate_schema_for_client
    await generator.generate_from_string(schema)
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/backends/base/schema_generator.py", line 504, in generate_from_
string
    await self.client.execute_script(creation_string)
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/backends/sqlite/client.py", line 43, in translate_exceptions_
    return await func(self, query, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/backends/sqlite/client.py", line 167, in execute_script
    async with self.acquire_connection() as connection:
               ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/backends/base/client.py", line 266, in __aenter__
    await self.ensure_connection()
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/backends/base/client.py", line 261, in ensure_connection
    await self.client.create_connection(with_db=True)
  File "/home/donlon/works/.venv/lib/python3.14/site-packages/tortoise/backends/sqlite/client.py", line 82, in create_connection
    self._connection.start()
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Connection' object has no attribute 'start'

How Has This Been Tested?

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@donlon donlon changed the title Fix exception when creating aiosqlite connections on aiosqlite==1.22.0 Fix exception when creating aiosqlite connections on aiosqlite==0.22.0 Dec 13, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 14, 2025

CodSpeed Performance Report

Merging #2035 will not alter performance

Comparing donlon:develop (7570e09) with develop (dd9f9c5)

Summary

✅ 16 untouched

@coveralls
Copy link

Pull Request Test Coverage Report for Build 20197313985

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 90.728%

Totals Coverage Status
Change from base Build 20169305593: -0.001%
Covered Lines: 6631
Relevant Lines: 7194

💛 - Coveralls

@henadzit henadzit merged commit c885fc8 into tortoise:develop Dec 16, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tortoise.generate_schemas() raises exception

4 participants