Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jupysql + duckdb breaks if passing :NUMBER #901

Closed
edublancas opened this issue Sep 29, 2023 · 2 comments · Fixed by #910
Closed

jupysql + duckdb breaks if passing :NUMBER #901

edublancas opened this issue Sep 29, 2023 · 2 comments · Fixed by #910
Assignees

Comments

@edublancas
Copy link

Jupysql thinks that :NUMBER is a parameter in the query, but duckdb uses this syntax for slicing strings (just like Python), we need to fix and escape it so it works just like when we're using duckdb (I think we're already escaping some parameters so we can use that code as a reference).

I can escape manually to get it working:

image

but we should do the escaping automatically

Notebook:

import duckdb

conn = duckdb.connect()
conn.execute("select 'hello'[:2]").fetchall()
[('he',)]
%load_ext sql
%sql duckdb://

Connecting to 'duckdb://'

Set named_parameters to False (this is actual the default so shouldn't make a difference)

%config SqlMagic.named_parameters=False

This breaks, jupysql thinks [:2] is a parameter:

%%sql
select 'hello'[:2]

Running query in 'duckdb://'

RuntimeError: (sqlalchemy.exc.InvalidRequestError) A value is required for bind parameter '2'
[SQL: select 'hello'[?]]
[parameters: [{}]]
(Background on this error at: https://sqlalche.me/e/20/cd3x)
If you need help solving this issue, send us a message: https://ploomber.io/community
@edublancas
Copy link
Author

@bryannho what's the status here?

@bryannho
Copy link

bryannho commented Oct 5, 2023

@bryannho what's the status here?

Started working on this today, barring issues should be done by early next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants