I am trying use pyodbc
execute a Stored Procedures
('42000', '[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type nvarchar to int. (8114) (SQLExecDirectW)') with the User_id number field.
Here is my code:
jsonData = json.loads(data)
user_id = jsonData['user']['id']
Sreenname = jsonData['user']['screen_name']
name = jsonData['user']['name']
con.execute("exec sp_insertintoalltable user_id,Sreenname,name")
Your con.execute()
statement is not automatically picking the user_id
, Sreenname
and name
variables from Python; you need to pass those in explicitly, using bind parameters:
con.execute("exec sp_insertintoalltable ?, ?, ?", (user_id, Sreenname, name))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.