遇一山,过一山,处处有风景;只要勇敢向前,一路尽是繁花盛开。 | (点击查看→)【测试干货】python/java自动化、持续集成、性能、测开、简历、笔试面试等

python操作oracle实战

 

安装cx_Oracle

 

 

 

 

操作oracle

import cx_Oracle
conn = cx_Oracle.connect('test/test@192.168.168.168/oracledb')
cur1 = conn.cursor()
cur2 = conn.cursor()
cur3 = conn.cursor()

sql1 = "select t.* from authentication t"
cur1.execute(sql1)
# res = cur1.fetchmany(4) # 498409
res = cur1.fetchall()
# print(len(res))
s = 15800000000
for i in res:
    temp = "'"+i[0]+"'"
    print(temp)
    s = s + 1
    ss = "'"+str(s)+"'"
    print(ss)
    sql3 = "select t.* from userinfo t wehre t.auth_id = %s"%temp
    cur3.execute(sql3)
    res = cur3.fetchall()
    if len(res)==1:
        sql2 = "update userinfo t set t.user_account =%s where t.auth_id=%s"%(ss, temp)
        cur2.execute(sql2)
        conn.commit()
# conn.commit()
cur3.close()
cur2.close()
cur1.close()
conn.close()

  

posted @ 2017-10-09 19:29  全栈测试笔记  阅读(474)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end