금요일, 10월 12, 2007

cx_Oracle에서 prepare하여 사용하기 예제




python 에서 Oracle 사용하는 모듈









cx_Oracle에서 prepare하여 사용하기 예제









>>> ts = datetime.datetime.now()


>>> print ts


2007-03-10 20:12:02.109000


>>> cursor.prepare("INSERT INTO python_tstamps VALUES(:t_val)")


>>> cursor.setinputsizes(t_val=cx_Oracle.TIMESTAMP)


cursor.setinputsizes(t_val=cx_Oracle.TIMESTAMP)


>>> cursor.execute(None, {'t_val':ts}) <-- 이부분이 중요 포인트


>>> db.commit()









링크: http://www.oracle.com/technology/pub/articles/prez-python-timesanddates.html


댓글 없음: