connection = cx_Oracle.Connection(connection_string)
cursor = cx_Oracle.Cursor(connection)
cursor.execute(query)
result= cursor.fetchall()
cursor.close()
connection.close()
for row in result:
print row
connection_string is username/password@tsnmame
or
connection = cx_Oracle.Connection(connection_string)
cur = connection.cursor()
cur.executemany("insert into net_eqam_info (sample_date, eqamip, rf_output, l2tp_session_id, cmts_name, eqam_name) values (trunc(sysdate),:1,:2,:3,:4,:5)",[{'1': '172.19.214.21', '2': '39000', '3': '1.1.1', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}, {'1': '172.19.214.21', '2': '39001', '3': '1.1.2', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}])
connection.commit()
cur.close()
connection.close()
remember whe execute a batch query,first parameter is query with named parameter,second one is a list of dictionaries
No comments:
Post a Comment