I'm trying to use pymssql to execute a stored procedure. Currently, I
have an Excel spreadsheet that uses VBA in this manner:
Private Function CreateNewParrot (connDb As ADODB.Connectio n) As Long
Dim objCommand As ADODB.Command
Dim iParrot As Long
Dim bSuccess As Boolean
Set objCommand = CreateObject("A DODB.Command")
objCommand.Acti veConnection = connDb
objCommand.Comm andText = "create_new "
objCommand.Comm andType = adCmdStoredProc
objCommand.Para meters.Refresh
On Error Resume Next
Err.Clear
objCommand.Exec ute
bSuccess = (Err.Number = 0)
On Error GoTo 0
If (bSuccess) Then
If (IsNull(objComm and("@parrot")) ) Then
iParrot = 0
Else
iParrot = CLng(objCommand ("@parrot"))
End If
Else
iParrot = 0
End If
Set objCommand = Nothing
CreateNewParrot = iParrot
End Function
My attempts to translate this into a python script using pymssql have
so far been fruitless. Here is what I have tried:
Traceback (most recent call last):>>import pymssql
con = pymssql.connect (host='blah', user='blah', password='blah' , database='blah' )
cur = con.cursor()
command = 'exec create_new_parr ot'
cur.execute(c ommand, '@parrot')
File "<stdin>", line 1, in ?
File "C:\Program Files\Python\li b\site-packages\pymssq l.py", line
127, in execute
self.executeman y(operation, (params,))
File "C:\Program Files\Python\li b\site-packages\pymssq l.py", line
153, in executemany
raise DatabaseError, "internal error: %s" % self.__source.e rrmsg()
pymssql.Databas eError: internal error: SQL Server message 8114,
severity 16, state 5, procedure create_new_parr ot, line 0:
Error converting data type nvarchar to int.
DB-Lib error message 10007, severity 5:
General SQL Server error: Check messages from the SQL Server.
Any ideas?
Thanks.
<M>