Menu

cursor.execute issue

bugfreeit
2009-02-03
2013-04-29
  • bugfreeit

    bugfreeit - 2009-02-03

    I'm using
    windows xp64
    python 2.5
    pymssql 1.0.0 (installed with windows setup)

    the following code snippet generate an error

    >>> import pymssql
    >>> con = pymssql.connect(user="sa", password="xxxx", host="xp4buildste\\test", database="test_db")
    >>> cur=con.cursor()
    >>> cur.execute("select * from sys_config")

    Traceback (most recent call last):
      File "<pyshell#3>", line 1, in <module>
        cur.execute("select * from sys_config")
      File "D:\Python25\Lib\site-packages\pymssql.py", line 182, in execute
        self._source.execute_query(operation, params)
    TypeError: not all arguments converted during string formatting

    I get no error if I have a (at least) parameter to my query

    >>> cur.execute("select * from sys_config where 1=%d", 1)

    I saw example on the web using execute() w/o parameters, but I'm not able to have them run

    BTW _mssql.execute_query() works

    any ideas?

    cheers
    stefano

     
    • A

      A - 2009-02-03

      Yes I overlooked this. The quickest remedy is to change one line in pymssql.py:
             def execute(self, operation, params = None):
      into
             def execute(self, operation, params = ()):

      This will be fixed in 1.0.1 in a few days.

      Sorry for the inconvenience,
      Andrzej

       
      • bugfreeit

        bugfreeit - 2009-02-03

        thank you for the light-speed response!!!

        it works

        cheers
        stefano

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.