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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions