3

hNas@s^ddlZddlZddlZddlZdZdZdZda	dddZ
dd	Zd
dZdd
Z
ddZdS)N	localhostZ3306Z1521mysqlc Cs|dkrhytjt|||daWnHtjk
rf}z*|jd}|jd}d|d|aWYdd}~XnX|dkrdtjd	<y2|d
|dtdtd
|}t	j|aWn.t	j
k
r}zd|aWYdd}~XnXtjd
krt
dtdtS)Nr)hostuserpasswordZdatabaserzConnection Error -  Zoraclez'/u01/app/oracle/product/12.2.0/dbhome_1ZORACLE_HOME/@:testzCONN=>z<br>)mydbconnectrconnErrorargsosenvironport2oradb
DatabaseErrorconfigRUN_MODEprint)rZpswdZDBnameZDBtypeeerrorNumerrorMsgZconn_strr3/home/s/sultans/web/python/demo/5cookie/shop1/DB.pyrs"

"
$
rcCs*d}tjdkrtd|dy,tj}|j||j}|j}|jWnjt	j
k
r}z |j\}}d|d|}WYdd}~Xn.tj
k
r}zd|}WYdd}~XnX|r|}nRg}xL|D]D}	d}
i}x,|	D]$}||
}
|
d}|||<|
d7}
qW|j|qWtjdkr&td	|d|S)
NrzSQL=>z<br>zDatabase Error - rrrzRESULT=>)rrrrcursorexecutedescriptionZfetchallcloser
rrrrappend)sqlerrorr ZmetadatadatarrrresultrowidictZ	col_valueZcol_infoZcol_namerrrselect/s:


 

r,cCstjdkrtd|dy,tj}|j||jtj|j}Wnjt	j
k
r}z |j\}}d|d|}WYdd}~Xn.tj
k
r}zd|}WYdd}~XnXtjdkrtd|d|S)NrzSQL=>z<br>zDatabase Error - rzRESULT=>)rrrrr r!r#ZcommitZrowcountr
rrrr)r%r r(rrrrrrupdateTs 



 
r-cCst|}|S)N)r-)r%numRowsrrrinsertjsr/cCst|}|S)N)r-)r%r.rrrdeletessr0)r)rZpymysqlr
Z	cx_OraclerrrZport1rrrr,r-r/r0rrrr<module>s
%