Skip to content

Python: Named parameter binding not consistent with DBAPI (stdlib sqlite) #3520

Open

Description

@henryharbeck

What happened?

Relates to #3262 and #3362

ADBC expects param names to match exactly. E.g.,

cursor.execute("SELECT @a", {"@a": 1})
cursor.execute("SELECT :a", {":a": 1})

Whereas other DBAPI implementations such as the Python sqlite standard library do not expect the paramstyle special character to be part of the name. E.g.,

cursor.execute("SELECT @a", {"a": 1})
cursor.execute("SELECT :a", {"a": 1})

Stack Trace

No response

How can we reproduce the bug?

import sqlite3

import adbc_driver_sqlite.dbapi

query = "SELECT :a"

for param_value in [
    {"a": 1},  # Correct per DBAPI, fails with ADBC
    {":a": 1},  # Works with ADBC, but not sqlite
]:
    print(f"{param_value = }")

    with adbc_driver_sqlite.dbapi.connect() as adbc_conn:
        adbc_cursor = adbc_conn.cursor()
        try:
            adbc_cursor.execute(query, param_value)
            adbc_res = adbc_cursor.fetchone()
            print(f"{adbc_res = }")
        except Exception as e:
            print(f"adbc_res = {str(e)}")
        adbc_cursor.close()

    with sqlite3.connect(":memory:") as sqlite_conn:
        sqlite_cursor = sqlite_conn.cursor()
        try:
            sqlite_cursor.execute(query, param_value)
            sqlite_res = sqlite_cursor.fetchone()
            print(f"{sqlite_res = }", end="\n\n")
        except Exception as e:
            print(f"sqlite_res = {str(e)}", end="\n\n")
        sqlite_cursor.close()

Output

param_value = {'a': 1}
adbc_res = INVALID_ARGUMENT: could not find parameter `a`
sqlite_res = (1,)

param_value = {':a': 1}
adbc_res = (1,)
sqlite_res = You did not supply a value for binding parameter :a.

Environment/Setup

Platform:             Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.31
Python:               3.11.8

adbc_driver_manager:  1.8.0
adbc_driver_sqlite:   1.8.0
pyarrow:              21.0.0

Activity

  1. lidavidm commented on Oct 6, 2025

    @lidavidm
    Member

    Hmm, I should more explicitly document that paramstyle is the part of DB-API that we intentionally don't try to emulate very well. But it seems reasonable for the SQLite driver to be more forgiving here.

  2. emecii commented on Sep 10, 2026

    @emecii
    Contributor

    take

  3. emecii commented on Sep 10, 2026

    @emecii
    Contributor

    I will work on accepting unprefixed SQLite named parameters while preserving exact prefixed names and rejecting ambiguous matches. I plan to add native and Python regression tests. This comment and the implementation work are AI-assisted using OpenAI Codex.

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

Metadata

Metadata

Assignees

Labels

Type: bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions