Python connects Oracle (cx_oracle module)

Source: Internet
Author: User
Connect to Oracle database using Python;
1. Install python3.0;
2. Install the Cx_oracle module;
3. Install oracle_client;
(Oracle_client and Python bits are consistent; either install 32-bit or all 64-bit)

导入连接oracle的模块import cx_Oracle#获取连接username=用户名pass=密码ipadd=数据库地址sid=数据库实例conn=cx_Oracle.connect(‘username/[email protected]/sid‘)c=conn.cursor()sql="sql语句"#执行sqlx=c.execute(sql)#得到结果列表relist = c.fetchall()#循环结果列表for i in serlist:    print(i)        #如果是增删改操作需要commit提交才会写入到数据库        #conn.commit()#关闭连接c.close()

Python connects Oracle (cx_oracle module)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.