Python Learning-Connecting to Oracle Database

Source: Internet
Author: User

We may need to manipulate the Oracle database in our tests, such as a scenario where the data is inserted into Oracle while another tool reads from it, and how to ensure that the data being read is sequential, that is, first inserted into the first read out, According to this scenario, you first need to create a script that continually inserts data into the Oracle database. This time we think of the Python cx_oracle library, which we will implement:

Import Cx_oracleimport timeisotimeformat= '%y-%m-%d%x ' def connectoracle (): Conn=cx_oracle.connect (' Dwa/[email Protected]:1521/orcl ') cursor=conn.cursor ()  cursor.execute ("drop table Test_increase") Cursor.execute ("Create Table Test_increase (F1 CHAR) ") 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.E Xecute (' Commit ') print "%d,%s"% (i,c_time) cursor.close () conn.close () if __name = = ' __main__ ': connectoracle ()  

More information: www.kootest.com; Technology Exchange Group: 182526995

Python Learning-Connecting to Oracle Database

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.