google-code-export / pymssql

Automatically exported from code.google.com/p/pymssql
GNU Lesser General Public License v2.1
0 stars 0 forks source link

callproc do not accept None and unicode string in parameters #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Steps for reproduce:
1. Simple code (file callproc_err.py)
conn = pymssql.connect(...)
curs = conn.cursor()
curs.callproc('someProcWithOneParam', [None])

2. Exec simple code
python callproc_err.py
Traceback (most recent call last):
...
  File "pymssql.pyx", line 357, in pymssql.Cursor.callproc (pymssql.c:3747)
    raise NotSupportedError('Unable to determine database type')
pymssql.NotSupportedError: Unable to determine database type

If change callproc parameters to [u'']:
curs.callproc('someProcWithOneParam', [u''])
Recive identical exception.

Original issue reported on code.google.com by tonal.pr...@gmail.com on 3 Jun 2011 at 4:24

GoogleCodeExporter commented 9 years ago
I have worked corrected path:
===============Start path================
diff -r 66579aff6824 pymssql.pyx
--- a/pymssql.pyx       Tue May 31 20:48:09 2011 -0400
+++ b/pymssql.pyx       Fri Jun 03 11:25:47 2011 +0700
@@ -78,11 +78,14 @@
 cdef dict DBTYPES = {
     'bool': _mssql.SQLBITN,
     'str': _mssql.SQLVARCHAR,
+    'unicode': _mssql.SQLVARCHAR,
     'int': _mssql.SQLINTN,
     'long': _mssql.SQLINT8,
     'Decimal': _mssql.SQLDECIMAL,
     'datetime': _mssql.SQLDATETIME,
-    'date': _mssql.SQLDATETIME
+    'date': _mssql.SQLDATETIME,
+    #Dump type for work vith None
+    'NoneType': _mssql.SQLVARCHAR,
 }

 # exception hierarchy
@@ -351,7 +354,7 @@
                 type_name = param_type.__name__
                 db_type = DBTYPES[type_name]
             except (AttributeError, KeyError):
-                raise NotSupportedError('Unable to determine database type')
+                raise NotSupportedError('Unable to determine database type 
from python %s type' % type_name)

             proc.bind(param_value, db_type, output=param_output)
         self._returnvalue = proc.execute()
===============End path================

Original comment by tonal.pr...@gmail.com on 3 Jun 2011 at 4:28

GoogleCodeExporter commented 9 years ago
My environment:
Os Kubuntu 11.04 with all latest updates
Python 2.7.1+ (2.7.1-0ubuntu5)
cython 0.13-1build1
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
pymssql source from hg (hg summary: parent: 214:66579aff6824 tip)

Original comment by tonal.pr...@gmail.com on 3 Jun 2011 at 8:22

GoogleCodeExporter commented 9 years ago

Original comment by rsyr...@gmail.com on 8 Mar 2012 at 3:22

GoogleCodeExporter commented 9 years ago
I found a temporary solution to the "None" problem by using the _mssql module.  
See my answer to my thread at StackOverflow: 
http://stackoverflow.com/questions/12938301/passing-nulls-to-stored-procedure-in
-python

Original comment by mke...@gmail.com on 17 Oct 2012 at 8:31

GoogleCodeExporter commented 9 years ago

Original comment by msabr...@gmail.com on 9 Jan 2013 at 5:14

GoogleCodeExporter commented 9 years ago
Just committed the patch from tonal.promsoft and also some tests. One of the 
tests fails which I think is another bug in how callproc handles Unicode 
strings - if this is not user error on my part then we should probably open a 
separate bug for that issue. tonal.promsoft, could you verify perhaps?

http://code.google.com/p/pymssql/source/detail?r=939eb7939136c8c7c61a6475e0f6fbe
dfbd8ded5

Original comment by msabr...@gmail.com on 9 Jan 2013 at 5:23

GoogleCodeExporter commented 9 years ago

Original comment by msabr...@gmail.com on 10 Jan 2013 at 1:09