DB
python:200526-pyDB_ver001.01, insert 단건, 다건 , oracle 기준
최무회
2020. 5. 26. 15:37
oracle DB 코드
--select sysdate from dual;
--EXEC dbms_xdb.sethttpport(9090);
--SELECT dbms_xdb.gethttpport() FROM DUAL;
--alter table VITA5 modify(GN_EVALUATION varchar2(4000));
--alter table VITA5 modify(GN_CONTENT varchar2(4000));
--COMMIT;
--select a.sid, a.serial# from v$session a, v$lock b, dba_objects c
--where a.sid=b.sid and b.id1=c.object_id and b.type='TM' and c.object_name='VITA5';
--ALTER SYSTEM KILL SESSION '169,195'
--DESC VITA5;
select * from VITA5;
python 코드 , dataframe to oracele table
# test code
# pythonToOracle-003
import sqlite3
import pandas as pd
import cx_Oracle
import time
import base64
con = cx_Oracle.connect("pytest001/1234@192.168.182.1:1521/xe")
con01 = con.cursor()
dataToInsert = [
('roh',
'일반 상품평',
'적극추천\n배송빠름',
'옵션없음\n적극추천 합니다. 배송이 빠릅니다.',
'2020.05.25',
'4906'),
('ddi',
'일반 상품평',
'적극추천\n배송빠름',
'옵션없음\n적극추천 합니다. 배송이 빠릅니다.',
'2020.05.25',
'4906'),
('kim',
'일반 상품평',
'적극추천\n배송빠름',
'옵션없음\n적극추천 합니다. 배송이 빠릅니다.',
'2020.05.25',
'4906')
]
dataToInsert
# con01.execute("DELETE FROM VITA5 ")
# con01.execute("select * from VITA5")
con01.executemany("insert into PYTEST001.VITA5 values (:1, :2, :3, :4, :5, :6)", dataToInsert)
con.commit()
con01.close()
print('success01')