-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add parametrized queries #137
Add parametrized queries #137
Conversation
This reverts commit 3e15aee.
src/sql/command.py
Outdated
"Please aware the variable substition" | ||
" as {a}, $a, and :a format has been deprecated." | ||
) | ||
print("Use {{a}} instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, let's add a tutorial in our docs describing this feature, and include the link to it
e.g., https://jupysql.ploomber.io/en/latest/user-guide/templating.html
https://github.com/ploomber/contributing/blob/main/documentation/notebooks.md
also in the current documentation where we explain the variable substitution, let's add a deprecation notice
```{versionchanged} 0.5.7
This has been deprecated use '{{a}}' [and add link to the new tutorial
```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah and one more thing: let's add a new document in the user guide where we list the incompatibilities with the ipython-sql project. just 1-2 sentences saying we use {{a}} instead of the old method and a link to the tutorial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New template page in user-guide: https://jupysql--137.org.readthedocs.build/en/137/user-guide/template.html
Add deprecation notice in intro: https://jupysql--137.org.readthedocs.build/en/137/intro.html#variable-substitution
Please ignore the latest build fail, since the new page user-guide/template.html
haven't deployed to jupysql.ploomber.io
, it won't pass the broken-links
action in our CI
…ing-parametrized-queries
Looks like the CI is failing on broken links |
Yes. this is expected, #137 (comment) Since we added the new page The second newest commit 6c4d9cb is a success build, since it it's without referring the template page. The latest commit is with that |
This reverts commit dff8b23.
The see more link wouldn't pass the broken-link, revert for now |
looks like the docs are failing, my guess is that this is due to the new jupyter book version: https://github.com/executablebooks/jupyter-book/releases let's pin to |
@edublancas |
Describe your changes
1. Disable the default IPython var_expand for
{a}, $a
caseWe disable the default variable substitution by adding @no_var_expand to the line_magic, since we still need to support the default variable substitution + new parametrized fashion in recent versions, we move that parsing part in the
SQLCommand
class2. Add
_var_expand
inSQLCommand
classThe logic for supporting
{a}, $a
(IPython) +{{a}}
(new param feature) variable substitution is:This execution order matters, since
{a}
is the subset of{{a}},
we need to handle the{{a}}
case before being handled by{a}
P.S. After those string are parsed, the
:a
part will still be kept, since it's handled by SQLAlchemy engineConclusion
This PR fulfill three requirements:
{a}, $a, :a
. We display message (can be discussed){{a}}
fashion, the values will fetch from user name space nowPreview
:a
- with deprecated message{a}
- with deprecated message$a
- with deprecated message{{a}}
- new parameter - consumed value from existing scopeFollow up
We need to support the arg --param & --use-global with {{a}} format in next PR
Issue ticket number and link
Closes #93
Checklist before requesting a review
📚 Documentation preview 📚: https://jupysql--137.org.readthedocs.build/en/137/