![](/img/trans.png)
[英]Not able to create database using stored procedure pyodbc SQL SERVER
[英]Stored procedure in pandas different database - Sql server
將 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)
但是,當我嘗試運行與存儲過程相同的代碼時,數據幀返回“TypeError: 'NoneType' object is not iterable”。
sql = " Use database2 exec dbo.Open_Accounts "
我也知道你不能在 pyodbc 中使用 go 命令
USE [database2]
GO
EXEC [dbo].[Open_Accounts]
GO
因此不能直接使用 SQL 代碼。
EXEC Database2..Open_Accounts ?? --如果有任何參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.