Utility functions for easier usage of SQL Server Machine Learning Services
Перейти к файлу
Jonathan Zhu 789d4f60c4 Update R version with Linux support 2019-05-22 12:51:40 -07:00
Python add port param for ConnectionInfo 2019-05-14 15:02:37 -07:00
R Update R version with Linux support 2019-05-22 12:51:40 -07:00
Travis-CI Update Travis CI Ubuntu version and enable Linux in R package management (#35) 2019-04-22 17:58:44 -07:00
.gitignore add Travis 2018-10-29 14:00:05 -07:00
.travis.yml fix R version for testing 2019-05-15 10:55:04 -07:00
AirlineTestDB.bak downgrade bak SQL version and add Airline test users (#15) 2019-01-31 11:52:19 -08:00
CONTRIBUTING.md Initial Commit 2018-09-24 11:59:34 -07:00
LICENSE Initial Commit 2018-09-24 11:59:34 -07:00
README.md Update install instructions to new version (#36) 2019-04-24 10:46:56 -07:00

README.md

sqlmlutils

Build Status

sqlmlutils is a package designed to help users interact with SQL databases (SQL Server and Azure SQL Database) and execute R or Python code in SQL from an R/Python client. Currently, only the R version of sqlmlutils is supported in Azure SQL Database. Python support will be added later.

Installation

To install sqlmlutils from this repository, run the following commands from the root folder:

Python:

  1. If your client is a Linux machine, you can skip this step. If your client is a Windows machine: go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql and download the correct version of pymssql for your client. Run pip install pymssql-2.1.4.dev5-cpXX-cpXXm-win_amd64.whl on that file to install pymssql.
  2. Run
python.exe -m pip install --upgrade --upgrade-strategy only-if-needed Python/dist/sqlmlutils-0.5.0.zip

R:

R -e "install.packages('RODBCext', repos='https://cran.microsoft.com')"
R CMD INSTALL R/dist/sqlmlutils_0.5.1.zip

Details

sqlmlutils contains 3 main parts:

  • Execution of Python/R in SQL databases using sp_execute_external_script
  • Creation and execution of stored procedures created from scripts and functions
  • Install and manage packages in SQL databases

For more specifics and examples of how to use each language's API, look at the README in the respective folder.

Execute in SQL

Execute in SQL provides a convenient way for the user to execute arbitrary Python/R code inside a SQL database using an sp_execute_external_script. The user does not have to know any t-sql to use this function. Function arguments are serialized into binary and passed into the t-sql script that is generated. Warnings and printed output will be printed at the end of execution, and any results returned by the function will be passed back to the client.

Stored Procedures (Sprocs)

The goal of this utility is to allow users to create and execute stored procedures on their database without needing to know the exact syntax of creating one. Functions and scripts are wrapped into a stored procedure and registered into a database, then can be executed from the Python/R client.

Package Management

With package management users can install packages to a remote SQL database from a client machine. The packages are downloaded on the client and then sent over to SQL databases where they will be installed into library folders. The folders are per-database so packages will always be installed and made available for a specific database. The package management APIs provided a PUBLIC and PRIVATE folders. Packages in the PUBLIC folder are accessible to all database users. Packages in the PRIVATE folder are only accessible by the user who installed the package.