我正在使用Win10 x64、Server 2017 x64、JyputerNotebook并使用主RevoScalePy库。
我可以建立到本地服务器的连接,创建db,查询表等。但是,当我定义一个函数返回图像的字节流并按如下方式调用该函数时:
from IPython import display
import matplotlib.pyplot as plt
from revoscalepy import RxInSqlServer, rx_exec
# create a remote compute context with connection to SQL Server
sql_compute_context = RxInSqlServer(connection_string=connection_string.format(new_db_name))
# use rx_exec to send the function execution to SQL Server
image = rx_exec(send_this_func_to_sql, compute_context=sql_compute_context)[0]
# only an image was returned to my jupyter client. All data remained secure and was manipulated in my db.
display.Image(data=image)...I得到一个错误:
MicrosoftSQL ServerLogin为用户‘NB-IT-JIRAK\IT 01’失败。 SQLDisconnect中的ODBC错误 无法打开数据源。ImportDataSource函数失败。有关更多信息,请参见控制台输出。
我遵循本教程:https://blogs.msdn.microsoft.com/mlserver/2018/07/10/run-r-and-python-remotely-in-sql-server-from-jupyter-notebooks-or-any-ide/,我尝试在我的控制面板/管理工具/数据源中的MS驱动程序之外为Server 17驱动程序创建一个新的DNS。我会感谢你的帮助。
发布于 2018-11-24 16:38:13
我认为您正在尝试从Server导入数据,对吗?这边试试。
import pypyodbc
cnxn = pypyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=Server_Name;"
"Database=DB_Name;"
"Trusted_Connection=yes;")
#cursor = cnxn.cursor()
#cursor.execute("select * from Actions")
cursor = cnxn.cursor()
cursor.execute('SELECT * FROM Actions')
for row in cursor:
print('row = %r' % (row,))在你的业余时间里,这里有几个资源可以让你眉目传情。
examples.html
http://blogs.msdn.com/b/cdndevs/archive/2015/03/11/python-and-data-sql-server-as-a-data-source-for-python-applications.aspx
发布于 2019-11-25 20:11:28
可选(可信连接字符串)
cnxn = pyodbc.connect(''DRIVER=SQL Server;SERVER={server_name};DATABASE={db-name};Trusted_Connection=True;'')
cursor = cnxn.cursor()
cursor.execute("EXECUTE [dbo].[PyPlotMatplotlib]")https://stackoverflow.com/questions/53459874
复制相似问题