pls help me with strange result

eight02645999 at yahoo.com eight02645999 at yahoo.com
Mon Nov 7 03:53:08 EST 2005


hi
i defined a func

db  = Sybase.connect(DSN) ....
...
def x_dml(SQL,conn):
        ''' Connects to database specified, exec the SQL and returns
value'''
        try:
                c = conn.cursor()
                try:
                        c.execute(SQL)
                        res = c.rowcount
                        conn.commit()
                        return res
                except :
                        return -1
        except:
                return -2
stmt = """
    update table1 set col = '%s' where col = '%s'
    update table2 set col = '%s' where col = '%s'
     """ % ( blah, blah ,blah,blah)

try:
    r = x_dml(stmt,db)
    if r > 0:
       print r
except:
    print "some error"


Whenever i execute x_dml , it raise the exeception, even though my r is
value of 1 and i checked the database tables, they are updated with
what i want.
somehow the condition r>0 did not work..any advice ?
thanks




More information about the Python-list mailing list