Python: Named parameter binding not consistent with DBAPI (stdlib sqlite)
- Dominant language
- C#
- Stars
- 627
- Forks
- 217
- Avg merge
- 17h
- Merged PRs (30d)
- 57
Description
### What happened?
Relates to https://github.com/apache/arrow-adbc/issues/3262 and https://github.com/apache/arrow-adbc/pull/3362
ADBC expects param names to match exactly. E.g.,
```python
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.,
```python
cursor.execute("SELECT @a", {"a": 1})
cursor.execute("SELECT :a", {"a": 1})
```
### Stack Trace
_No response_
### How can we reproduce the bug?
```python
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
```
Contributor guide
Assessment
This issue has not been assessed yet.