Skip to content

sqlite3 completion fail on attached names with quotes #153768

Description

@lkk7

Bug report

Bug description:

Tab completion fails in sqlite3 when the name of an attached DB contains a quote.

Minimal code repro:

import sqlite3
from sqlite3._completer import _complete

con = sqlite3.connect(":memory:")
con.execute("""ATTACH ':memory:' AS [has"quote]""")
con.execute("""CREATE TABLE [has"quote].example_table(value)""")
print(_complete(con, "exam", 0)) # sqlite3.OperationalError: unrecognized token: "".sqlite_master
con.close()

Minimal CLI repro if you prefer:

(open the CLI)
>>> <python executable≥ -m sqlite3
(in CLI):
>>> ATTACH ':memory:' AS "has""quote";
>>> CREATE TABLE "has""quote".example_table(value);
>>> SELECT * FROM exam<press tab here and it doesn't work>

CPython versions tested on:

CPython main branch, 3.15

Operating systems tested on:

macOS

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-sqlite3type-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions