Re: [cx-oracle-users] Update problem
Brought to you by:
atuining
From: Amaury F. d'A. <ama...@gm...> - 2007-01-17 10:38:10
|
2007/1/16, Jesse G. Lands <jg...@be...>: > I have some code that works fine when I query, but when try an update > statement I get a response back of > "Expecting string or none" > > my code looks something like this > [code] > > import cx_Oracle > from pprint import pprint > xl = readexcel('users701.xls') > sheetnames = xl.worksheets() > dbuser = 'user/password@blue' > connect = cx_Oracle.Connection("%s" % (dbuser)) > cursor = cx_Oracle.Cursor(connect) > i = 1 > for sheet in sheetnames: > > for row in xl.getiter(sheet): > #sql = "select * from T_PERSONNEL" > if (i > 50): > break > sql = """UPDATE T_PERSONNEL SET last_name = > '%s',first_name = '%s' WHERE login = '%s'""" % (row['Last Name'], > row['First Name'], row['ID']) > print sql, cursor.execute(sql) > #data = cursor.fetchall() > #pprint(data) > i = i + 1 One possibility is that your query is actually a unicode string. This happens if your excel data are returned as unicode. Unicode query are not (yet) supported by cx_Oracle. I suggest to try a conversion to string: cursor.execute(str(sql)) -- Amaury Forgeot d'Arc |