我在下面的代码中遇到错误:
import cx_Oracle
conn=cx_Oracle.connect("system/root")
cur=conn.cursor()
cur.execute("INSERT INTO item VALUES('C109','FMCG','storage',50,'10
items','50 items','hard disk')")
p1=cur.execute("SELECT itemprice FROM item WHERE itemtype='FMCG'")
query="UPDATE TABLE item SET itemprice=%d WHERE itemtype='FMCG'"
updatedprice=p1*.03+p1
#updatedprice= float
data=[updatedprice]
cur.executemany(query,data)
cur.execute("SELECT price FROM item WHERE itemtype='FMCG'")
print(cur.fetchall())
我只需要使用executemany将价格提高3%。
错误是:
Traceback (most recent call last):
File "C:/Users/Simran/PycharmProjects/Assignment2/db_a8.py", line 10, in
<module>
updatedprice=p1*.03+p1
TypeError: unsupported operand type(s) for *: 'cx_Oracle.Cursor' and 'float'