Kevonia Tomlinson
Kevonia Tomlinson

Reputation: 80

('42000', '[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type nvarchar to int. (8114) (SQLExecDirectW)')

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")

Upvotes: 0

Views: 18208

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121226

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))

Upvotes: 2

Related Questions