How To Run R & Python in SQL Server from Jupyter Notebooks or any IDE

How To Run R & Python in SQL Server from Jupyter Notebooks or any IDE


Hey, everyone in this video you will learn how to send R and python execution in SQL server from your own ide. This is a great feature because, you know, longer have to transfer data out of SQL server to leverage R and python and you get to stay working and ide you are familiar with. No more waiting on long network transfers over odbc connections and we’re need to extract sample csv files to take your client. Write your code where you want it and send the execution to SQL server where your data lives While this video will show you an example of python and jupiter notebooks you can do the same thing with r and you can use any tool you like, like R studio visual studio, vs code pycharm et cetera. In order to complete the steps and this video you’ll need machine learning services installed on SQL server check out the description below for a link to another video to help you get set up. in order to send python execution from a client jupiter notebook to SQL server we need to leverage a microsoft library called RevoscalePy. you can get revoscalepy on your client machine by downloading our python client from the documentation page linked in the video description below this is an anaconda distribution with revoscalepy and many other popular data science open-source packages pre installed after downloading installation script open up our shows administrator execute this script with the install folder command specifying where you want python client installed. be patient while this installation may take a little while. Once installed navigate to the path you installed in and open jupiter notebooks with this command let’s create a new notebook by clicking new, python three to test everything is set up import revoscalepy in the first cell and execute if there are no error messages you’re ready to move forward. To copy paste the code you see in my jupiter notebook check out the video description below first we’re going to set of sequel with the well-known iris data set. this first cell uses pyodbc to create a database modify the connection string for your information and execute. This cell imports the built-in iris data set from the sk learn package. This cell leverages revoscalepy to insert the data into the new table. Now that you databases setup let’s write a function that we want to remotely execute in SQL server. define any function you want to send in this case we’re going to make a scatter matrix of the iris dataset. Specify what you want to return back to your client machine. in this example I only return the byte stream of the scatter matrix image so I can visualize and explore the results in jupyter notebooks. Now using revoscalepy I specify a remote compute context with a connection stream to my SQL Server Using RxExec I can ship off the function to be executed in SQL. All of the computation happens there and only the image byte stream is return for me to display in my jupyter notebook now I know we had to do a few set up steps so that you could follow my code in this tutorial, but once you’re setup check how easy this really is all we have to do was import revoscalepy create a SQL compute context and then send the execution of any function seamlessly to SQL server with RxExec. You now know how to send R and python execution from any IDE to SQL server. Check out links in the description below to learn more and see how you can also write R and python directly in your t-SQL statements

Leave a Reply

Your email address will not be published. Required fields are marked *