最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Share SQL result to Python with Polyglot Notebook extension in VScode - Stack Overflow

programmeradmin2浏览0评论

Well my question is if there is a way to work in SQL (in Polyglot notebook) and save tables as a objects or variables, and them go to a Python cell (in the same Polyglot notebook) to work the tables with Python.

So, as in the screen capture I would like yo share the temporary table #tmp3 and work in Python.

I'm using Polyglot v1.0.6160010 extension in VScode.

Thanks a lot for the help! By!

Well my question is if there is a way to work in SQL (in Polyglot notebook) and save tables as a objects or variables, and them go to a Python cell (in the same Polyglot notebook) to work the tables with Python.

So, as in the screen capture I would like yo share the temporary table #tmp3 and work in Python.

I'm using Polyglot v1.0.6160010 extension in VScode.

Thanks a lot for the help! By!

Share Improve this question asked Mar 19 at 20:52 Ronald RiveraRonald Rivera 333 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Found the answare here.

First install packages.

#r "nuget:Microsoft.DotNet.Interactive.SqlServer,*-*"

Then create the kernels of SQL and Python.

I use a conda environment.

#!connect mssql --kernel-name DB "Server=server_name;Database=DB_name;Integrated Security=True;TrustServerCertificate=true;"

#!connect jupyter --kernel-name python --conda-env env_prueba2 --kernel-spec python3

And them to share data between languages in the same notebook.

Extract from SQL Server a query.

Note the first line, the data as a name to share from SQL to Python.


And now it can be use with Python.

As you can see the query result save in pandas dataframe.

The only problem that I found is that querys result must to be small. I try share 500,000 rows and crash.

By!

发布评论

评论列表(0)

  1. 暂无评论