简体   繁体   English

pandas不同数据库中的存储过程 - Sql server

[英]Stored procedure in pandas different database - Sql server

Running this code snippet works fine when typing the sql command directly into python.将 sql 命令直接输入 python 时,运行此代码片段效果很好。

cnxn = pyodbc.connect(driver and login details go here)
sql = """ sql command that produces a table from the main database """
df = pd.io.sql.read_sql_query(sql, cnxn)

However, the dataframe returns a 'TypeError: 'NoneType' object is not iterable', when I try to run the same code as a stored procedure.但是,当我尝试运行与存储过程相同的代码时,数据帧返回“TypeError: 'NoneType' object is not iterable”。

sql = " Use database2 exec dbo.Open_Accounts "

I am also aware that you can't use the go command in pyodbc我也知道你不能在 pyodbc 中使用 go 命令

USE [database2]
GO
EXEC    [dbo].[Open_Accounts]
GO

and thus can't use the SQL code directly.因此不能直接使用 SQL 代码。

EXEC Database2..Open_Accounts ?? EXEC Database2..Open_Accounts ?? --IF ANy Parameter There. --如果有任何参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM