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

Add capability to embed SQL queries inside .py scripts #449

Closed
lfunderburk opened this issue Apr 25, 2023 · 2 comments · Fixed by #558
Closed

Add capability to embed SQL queries inside .py scripts #449

lfunderburk opened this issue Apr 25, 2023 · 2 comments · Fixed by #558
Assignees
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers stash Label used to categorize issues that will be worked on next

Comments

@lfunderburk
Copy link

This question came up in two scenarios:

  1. From a SQL user who is looking for ways to easily integrate SQL queries using .py scripts. They don't work with Jupyter notebooks in their applications and they want the ability to execute queries with a similar ease.
  2. For the deepset tutorial, the devrel I am working with also wondered whether it was possible to script the queries within .py files

If not possible, can you advise of an alternative approach we can take?

@edublancas
Copy link

Yes, they can use .py scripts using the percent format. VSCode and Spyder support this:

image

Let's keep this open, I think we should have a tutorial about this.


If they don't want to use the .py percent format, it's also possible to use JupySQL using the Python API, we should document that as well. But that's gonna take more time as we might need to make some changes to the codebase.

@edublancas edublancas added documentation Improvements or additions to documentation good first issue Good for newcomers labels May 23, 2023
@edublancas
Copy link

we can create a new user guide showing how to use jupySQL with .py files. VSCode should work just fine (as I showed in the screenshot) but I believe JupyterLab might need some tweaks.

Users can open .py as notebooks in JupyterLab using jupytext; however, I remember having some issues so we need to check if they're still happening:

  • create a notebook and include some SQL cells with arguments example%%sql --save
  • convert the notebook to py:percent format using jupysql
  • open the new .py file as a notebook (this should be enabled once jupytext is activated)
  • add a new cell with arguments %%sql --save, save the .py file, close it
  • re-open the file again, check if the arguments still appear in the right place

@edublancas edublancas added the stash Label used to categorize issues that will be worked on next label May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers stash Label used to categorize issues that will be worked on next
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants