I would say that the answer is no. I have not worked with VS Code, but I guess that you get one connection per window. And these connections could be to different SQL Server instances or databases. So it would be a limiting if a notebook had to piggyback on an existing connection. Also, you want the Jupyter notebook to be standing on its own. The next person who runs it may not have your connections.
Trying to Write Python Code from Connected Database
I have connected a data warehouse in VS Code via the MSSQL extension. It has successfully connected and I can query it directly. I now want to leverage SQL and Python within a singular notebook. All of the ways I have seen to do this require me to open a Jupyter Notebook and create a connection to a database. Since, I already have an existing connection via the extension, is there another way to do this?
I'd like to write a SQL query, generate a dataset, and then perform some analysis with Python on this. In one notebook, if possible. Is there a way to do this that doesn't require creating a new connection to the database? If not, it seems like connecting via the MSSQL extension wasn't very useful.