将Python库导入到SQL Server

我正在尝试在SQL Server Python脚本中“导入datefinder”,但是由于某些原因,它不起作用。其他库(例如Pandas)似乎也可以正常工作。

我已经尝试过使用Python跟踪脚本;

 import sqlmlutils  
 connection = sqlmlutils.ConnectionInfo(server="xxx",database="xxx")
 sqlmlutils.SQLPackageManager(connection).install("datefinder")

并收到以下错误消息;

  

MSSQLDatabaseException:(20009,b'DB-Lib错误消息20009,严重性   9:\ n无法连接:Adaptive Server不可用或没有   存在(xxx \ xxx)\ n')

当我尝试在SQL Server中运行脚本时,出现以下错误;

  

消息39004,级别16,状态20,第1行发生“ Python”脚本错误   在使用HRESULT执行'sp_execute_external_script'期间   0x80004004。消息39019,第16级,状态2,第1行外部脚本   发生错误:

     

执行错误。检查输出以获取更多信息。追溯   (最近一次通话最近):File中的文件“”,第5行   “ C:\ PROGRA〜1 \ micrOS〜4 \ MSSQL1〜1.DEV \ MSSQL \ EXTENS〜1 \ DEV201701 \ 64B0BBDF-3497-42E2-8C54-38CA1EA8CD85 \ sqlindb.py”,   第37行,进行转换       导入datefinder ImportError:没有名为“ datefinder”的模块

     

SqlSatelliteCall错误:执行错误。检查输出以了解更多   信息。

blackvip 回答:将Python库导入到SQL Server

https://thomaslarock.com/2018/05/adding-python-packages-to-sql-server-2017/

我能找到的最好的解释!

EXEC sp_execute_external_script
  @language =N'Python',@script=N'import sys; print("\n".join(sys.path))'

让您检索SQL Server使用的python环境的路径:

C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER2017\PYTHON_SERVICES\lib\site-packages\setuptools-27.2.0-py3.5.egg

打开命令行,向下导航到您的PYTHON_SERVICES/Scripts目录。 从那里致电pip install datefinder 您将需要拥有执行此操作的权利。

本文链接:https://www.f2er.com/3151648.html

大家都在问