本文转载自:http://python.6.x6.nabble.com/CPyUG-python-insert-oracle-td2740346.html
SQL如下:
INSERT INTO WEB_REPORT_TEST2(d_tid,d_type,d_uv,d_pv,d_ip,d_hour) values(110556,1,1,12,1,0) ;
Python代码如下:
SQL = "INSERT INTO "+TABLE_NAME+"(d_tid,d_type,d_uv,d_pv,d_ip,d_hour) values("+str(k)+','+str(D_TYPE)+','+str(v.get('uv'))+','+str(v.get('pv'))+','+str(v.get('ip'))+','+str(time_point)+''")"
print SQL
cu.execute(SQL)
在sqlplus中执行正常。
在python中则出现:
cx_Oracle.DatabaseError: ORA-00911: invalid character
搜索了一下,说是;的问题,去掉后报错如下:
cx_Oracle.DatabaseError: ORA-00972: identifier is too long