[egenix-users] unixODBC SQLSEVER OUPUT issue

akm a.km.mail at gmail.com
Tue Apr 21 17:27:52 CEST 2009


Hi,

I am getting the result when i change the parameter style to '%'  from '?'.
Any idea how to fix this ?

>>> from mx.ODBC import unixODBC
>>> db = unixODBC.DriverConnect('dsn=mydsn;uid=user;pwd=passwd', clear_auto_commit = 1)
>>> conn = db.cursor()
>>> query_insert1 = """INSERT INTO [table_name]
...                           (
...                           [description],
...                           [condition],
...                           [units],
...                           [entity_active],
...                           [crt_dt],
...                           [upd_dt],
...                           [user_idn])
...                           OUTPUT INSERTED.*
...                           VALUES(
...                           '%s',
...                           NULL,
...                           NULL,
...                           '%s',
...                           NULL,
...                           NULL,
...                           NULL)"""
>>> data = ('ERS', 'Y')
>>> conn.execute(query_insert1% data)
>>> print conn.fetchone()
(237.0, 'ERS', None, None, 'Y', None, None, None)
>>> conn.execute(query_insert1, data)
>>> print conn.fetchone()
None
>>> query_insert2 = """INSERT INTO [table_name]
...                           (
...                           [description],
...                           [condition],
...                           [units],
...                           [entity_active],
...                           [crt_dt],
...                           [upd_dt],
...                           [user_idn])
...                           OUTPUT INSERTED.*
...                           VALUES(
...                           ?,
...                           NULL,
...                           NULL,
...                           ?,
...                           NULL,
...                           NULL,
...                           NULL)"""
>>> conn.execute(query_insert2, data)
>>> print conn.fetchone()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
mx.ODBC.Error.ProgrammingError: missing result set


On Mon, Apr 20, 2009 at 8:27 PM, M.-A. Lemburg <mal at egenix.com> wrote:
> On 2009-04-20 15:26, akm wrote:
>> Hi  All,
>>
>> The query given below is supposed to return all columns from the table
>> 'table_name'  for the record with user '111'.
>> I am not getting any result from linux while excuting fetchone() , but
>> it works fine in windows.
>>
>> Can anyone give me a pointer why this occurs ?
>
> It's possible that MS SQL Server puts the output into a separate
> result set.
>
> You can use cursor.nextset() to jump to the next available result
> set.
>
>> #test.py
>> query = """update table_name
>>                           set upd_dt = getdate(),
>>                           user =222,
>>                 OUPUT INSERTED.*
>>                       where user =  111,
>>                """
>>
>> def connectToDataBase(connstr):
>>     if sys.platform == 'win32':
>>         from mx.ODBC import Windows
>>     db = Windows.DriverConnect(connstr, clear_auto_commit = 1)
>>         conn = db.cursor()
>>     else:
>>         from mx.ODBC import unixODBC
>>         db = unixODBC.DriverConnect(connstr, clear_auto_commit = 1)
>>         conn = db.cursor()
>>     conn.execute(result)
>>     print conn.fetchone()
>>
>> if __name__ == '__main__':
>>     print connectToDataBase('dsn=sb;uid=user;pwd=passwd')
>>
>>
>> Thanks,
>> Abdul Kader M
>>
>>
>> _______________________________________________________________________
>> eGenix.com User Mailing List                     http://www.egenix.com/
>> https://www.egenix.com/mailman/listinfo/egenix-users
>
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Source  (#1, Apr 20 2009)
>>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
> ________________________________________________________________________
>
> ::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
>
>
>   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
>    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>           Registered at Amtsgericht Duesseldorf: HRB 46611
>               http://www.egenix.com/company/contact/
>



More information about the egenix-users mailing list