Problem with Jupyter Notebook code/sql cells beeing changed automatically
We have some Jupyter Notebooks, and we recently introduced %%sql --save output, which enables testing the code in the Notebooks. Unfortunately, PyCharm automatically deletes this, and i have found no way to stop this behavior. i cant even edit the files in another program and then push them with PyCharm, even if i don't open them. as soon as PyCharm indexes the files the change is done.
We are working with PyCharm2025.2.
the problem occurs in our code cells that include sql. they look like this :
{
"cell_type": "code",
"execution_count": null,
"id": "some-id",
"metadata": {
"slideshow": {
"slide_type": ""
},
"tags": [
"a_tag"
]
},
"outputs": [],
"source": [
"%%sql --save output\n",
< some sql code here >
]
},Pycharm recognizes these as sql cells, and does not show the "%%sql --save output\n", line in its view of the Notebook.
it changes this cell to the following:
{
"cell_type": "code",
"execution_count": null,
"id": "some-id",
"metadata": {
"slideshow": {
"slide_type": ""
},
"tags": [
"a_tag"
]
},
"outputs": [],
"source": [
"%%sql\n",
< some sql code here >
]
},i also tried excluding notebooks from PyCharm as suggested here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/9800596213394-PyCharm-modifying-every-notebook-in-repo
this did not fix the issue.
as it stands, i have to completely avoid PyCharm for any commit which includes one of these Notebooks.
Please sign in to leave a comment.
Hi Marlene Kress, this issue requires thorough investigation, please create an issue on YouTrack (https://youtrack.jetbrains.com/issues/PY) and attach all relevant information for quicker resolution.