0

How can I install self-written library functions_lib.py into sql server.

The script:

CREATE EXTERNAL LIBRARY functions_lib 
FROM (CONTENT = 'my_destination_folder\functions_lib.py')
WITH (LANGUAGE = 'Python');
GO

leads to error: Incorrect syntax near 'Python'

I also tried to use the script according to the article:

import setuptools

setuptools.setup(name='mypackage')

but it leads to error:

An exception has occurred, use %tb to see the full traceback.

SystemExit: usage: ipykernel_launcher.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: ipykernel_launcher.py --help [cmd1 cmd2 ...]
   or: ipykernel_launcher.py --help-commands
   or: ipykernel_launcher.py cmd --help

error: option -f not recognized

More details: I have functions_lib.py self-written library which is placed into my working Jupiter Notebook folder. I import this library running in Jupiter Notebook:

import functions_lib as fl

Now I want to install this library on SQL Server. Usually I install the other external libraries by running the script from the command line:

cd C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\Scripts
pip.exe install destination_folder\xgboost-0.90-py2.py3-none-win_amd64.whl

Or by simple placing unpacked library folder into:

C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\

That worked well.

Alex Ivanov
  • 657
  • 1
  • 8
  • 17
  • 1
    You need SQL Server 2019 for Python language support, ref: [CREATE EXTERNAL LIBRARY (Transact-SQL)](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-external-library-transact-sql) – AlwaysLearning Jan 16 '20 at 10:45
  • jarlh, thank you. Is there another method for SQL Server 2017? – Alex Ivanov Jan 16 '20 at 10:51

0 Answers0