zoukankan      html  css  js  c++  java
  • python 连接oracle 数据库

    我们在测试中可能需要对oracle 数据库进行操纵,比如这样一个场景,在往oracle 里面插数据的同时,另一个工具从里面读,如何能保证读出来的数据是有顺序的,即:先插入进去的先读出来,根据这个场景们首先需要制作一个不断往oracle 数据库里面插入数据的脚本。这个时候我们想到了python 的cx_Oracle库,下面我们就来实现一下: 

    import cx_Oracle
    import time
    ISOTIMEFORMAT='%Y-%m-%d %X'
    def connectOracle():
    conn=cx_Oracle.connect('dwa/dwa@10.32.164.119:1521/orcl')
    cursor=conn.cursor()  
    cursor.execute("drop table test_increase")
    cursor.execute("create table test_increase ( f1 CHAR(256) )")
    cursor.execute("commit");
    for i in range(0,999999):
    c_time=time.strftime( ISOTIMEFORMAT, time.localtime( time.time() ) )
    cursor.execute("insert into dt_test_increase values ('%d')" % (i) )
    cursor.execute('commit')
    print "%d,%s" % (i,c_time)
    cursor.close()
    conn.close()
    if __name =='__main__':
    connectOracle()
      
    

    更多资料关注:www.kootest.com ;技术交流群:182526995  

  • 相关阅读:
    和为S的两个数字
    数字在排序数组中出现的次数
    连续子数组的最大和
    包含min函数的栈
    二进制中1的个数
    变态跳台阶
    android里R.layout.的问题
    eclipse里面设置JVM参数的问题
    perl小记
    机器寻径引导算法(最短路径表)__深搜、栈
  • 原文地址:https://www.cnblogs.com/kootest/p/4088074.html
Copyright © 2011-2022 走看看