ploomber / jupysql

Better SQL in Jupyter. 📊
https://jupysql.ploomber.io
Apache License 2.0
691 stars 74 forks source link

A value is required for bind parameter '1' #971

Open tekumara opened 8 months ago

tekumara commented 8 months ago

What happens?

RuntimeError: (sqlalchemy.exc.InvalidRequestError) A value is required for bind parameter '1'
[SQL: select json('[{"a"?}, {"b"?}]')]

but when run in the duckdb cli the result is:

❯ duckdb
v0.9.2 3c695d7ba9
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D select json('[{"a":1}, {"b":2}]');
┌────────────────────────────┐
│ json('[{"a":1}, {"b":2}]') │
│            json            │
├────────────────────────────┤
│ [{"a":1},{"b":2}]          │
└────────────────────────────┘

To Reproduce

%load_ext sql
%config SqlMagic.feedback = False
%config SqlMagic.displaycon = False
%config SqlMagic.autopandas = True
%sql duckdb:///:memory:
%sql select json('[{"a":1}, {"b":2}]')

OS:

macos

JupySQL Version:

0.10.7

Full Name:

Oliver Mannion

Affiliation:

Xero

edublancas commented 8 months ago

thanks for reporting this! this is related to https://github.com/ploomber/jupysql/issues/972, we can create a new option to disable parameter expansion because :1 is interpreted as a query parameter.

as a quick fix: adding a space (eg : 1) might fix the issue