Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite3.OperationalError: table [schemas] already exists #810

Open
imax opened this issue Mar 1, 2025 · 7 comments
Open

sqlite3.OperationalError: table [schemas] already exists #810

imax opened this issue Mar 1, 2025 · 7 comments

Comments

@imax
Copy link

imax commented Mar 1, 2025

i was trying to follow new schemas tutorial and keep getting this error with different commands

% llm schemas --full

Traceback (most recent call last):
  File "/Users/max/.local/bin/llm", line 10, in <module>
    sys.exit(cli())
             ~~~^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/llm/cli.py", line 1467, in schemas_list
    migrate(db)
    ~~~~~~~^^^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/llm/migrations.py", line 14, in migrate
    fn(db)
    ~~^^^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/llm/migrations.py", line 244, in m014_schemas
    db["schemas"].create(
    ~~~~~~~~~~~~~~~~~~~~^
        {
        ^
    ...<3 lines>...
        pk="id",
        ^^^^^^^^
    )
    ^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/sqlite_utils/db.py", line 1703, in create
    self.db.create_table(
    ~~~~~~~~~~~~~~~~~~~~^
        self.name,
        ^^^^^^^^^^
    ...<13 lines>...
        strict=strict,
        ^^^^^^^^^^^^^^
    )
    ^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/sqlite_utils/db.py", line 1084, in create_table
    self.execute(sql)
    ~~~~~~~~~~~~^^^^^
  File "/Users/max/.local/share/uv/tools/llm/lib/python3.13/site-packages/sqlite_utils/db.py", line 535, in execute
    return self.conn.execute(sql)
           ~~~~~~~~~~~~~~~~~^^^^^
sqlite3.OperationalError: table [schemas] already exists
@rdslw
Copy link

rdslw commented Mar 1, 2025

Also see this problem.

It started after simultaneous:

  • upgrade llm 0.22 -> llm 0.23
  • change from using pipx to uv for managing llm
    - swaping plugin ffrom claude to llm-anthropic

@rdslw
Copy link

rdslw commented Mar 1, 2025

please advise @simonw

@rdslw
Copy link

rdslw commented Mar 1, 2025

tried to downgrade to 0.22 and moving back to pipx, the problem persists.

@rdslw
Copy link

rdslw commented Mar 1, 2025

OK, did more thorough analysis.
TL;dr bug in llm 0.23 resulting in corrupt logs.db

Findings:

  • uv is not a culprit (pipx neither)
  • llm-anthropic is not a culprit
  • 0.22 works fine
  • during first run of 0.23, it tries to add schemas, there is a bug in code which leaves logs.db in a state resulting in an error, no matter which version being used -> hence simple downgrade does not help.

@krzyzanowskim
Copy link

any idea what to delete to restore to the state where it does not trigger the migration?

@krzyzanowskim
Copy link

manual delete ~Library/Application Support/io.datasette.llm/logs.db solves that for me

@imax
Copy link
Author

imax commented Mar 9, 2025

deleting the logs also worked for me

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

No branches or pull requests

3 participants