Re: [cx-oracle-users] Update problem
Brought to you by:
atuining
From: Jesse G. L. <jg...@be...> - 2007-01-17 17:06:16
|
On Wed, 17 Jan 2007 11:38:05 +0100 "Amaury Forgeot d'Arc" <ama...@gm...> wrote: > 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)) > That seemed to work. The only other problem I had was that the list names contained spaces. So I needed to modify the excel spreadsheet to fix this. Thank you very much for your help. -- JLands Arch Current Registered Linux User #290053 "It is better to be feared than loved, if you cannot be both." - Niccolo Machiavelli (1469-1527), "The Prince" |