[python-sybase] connect.execute() results

mike mik3l3374 at gmail.com
Wed Nov 2 20:06:18 EST 2005


hi
i am using the Sybase connecttion object "execute(sql)" to call an SQL
statement to my Sybase ASE

here is the statement that i want to execute. basically to change a user
password and update a table

SQL= '''
declare @res int
exec @res = sp_password 'sapass' ,'userpass', 'user'
if @res = 0
begin
update passwdtable set pswd = 'userpass' user_name = 'user'
select convert(int,1) --to return a int
end
else
begin
select convert(int,-1)
end
'''

In the sybase manual, it says under the "Connections object"
execute(sql)
......
The return value is a list of logical results. Each logical result is a list
of row tuples.
......

db = connect (....., auto_commit=1)
def exec_stmt(SQL):
try:
a,b = db.execute(SQL)
db.commit()
db.close()
return a,b
except Sybase.DatabaseError:
return -1
 c,d= exec_stmt(SQL)

when the result is returned, it shows a list of tuples ([(0,)], [(1,)]) .
the password is changed and the update is successful by the way.
may i know how to interpret this results of tuples?
thanks





-------------------------------------------------------------------------------------------------------------------------------------

  _______________________
Privileged/Confidential information may be contained in this message.
If you are not the intended recipient, please notify the sender immediately.
Check out our website at http://www.mpa.gov.sg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.object-craft.com.au/pipermail/python-sybase/attachments/20051102/5225a1a5/attachment.html


More information about the Python-sybase mailing list