Necessary component Installation
ActivePython python Windows Support components Unix-like systems have their own Python components download "Baidu ActivePython"
oracle_client Oracle Database Link Component "Cannot link to database if not installed"
cx_oracle python Oracle Link Support component ""http://sourceforge.jp/projects/sfnet_cx-oracle/releases/
installation process
Installing ActivePython and Oracle_client is the next way
Installing Cx_oracle
1. View the python version number
650) this.width=650; "title=" 1.png "src=" Http://s3.51cto.com/wyfs02/M02/59/B2/wKiom1TcKKLRKlkWAADf-3RkJkc759.jpg " alt= "Wkiom1tckklrklkwaadf-3rkjkc759.jpg"/>
If ActivePython is installed properly, entering Python on the command line will show the style shown above. You can see that the Python version number is
3.3.2.0. Then download the corresponding 32-bit cx_oracle.
650) this.width=650; "title=" 2.png "src=" Http://s3.51cto.com/wyfs02/M00/59/AF/wKioL1TcKiqifiC1AAKAseRBDJw450.jpg " alt= "Wkiol1tckiqific1aakaserbdjw450.jpg"/>
Download click Next to install
Test whether the cx_oracle is available
650) this.width=650; "title=" 3.png "src=" Http://s3.51cto.com/wyfs02/M01/59/AF/wKioL1TcKlqC7rVAAAEJarMLhSQ458.jpg " alt= "Wkiol1tcklqc7rvaaaejarmlhsq458.jpg"/>
Enter Import Cx_oracle If it is OK, the installation succeeds, if the prompt cannot find the DLL file, the DLL file below will be oracle_home/bin, copy to the installation directory of Python
650) this.width=650; "title=" 4.png "src=" Http://s3.51cto.com/wyfs02/M01/59/B2/wKiom1TcKYzTSnB1AAM4Udl5TSU155.jpg " alt= "Wkiom1tckyztsnb1aam4udl5tsu155.jpg"/>
Start Code Test
Develop a script that queries wages based on the Scott object
From pip.backwardcompat import raw_input__author__ = ' stone ' #引入oracle支持包import cx_oracle# linked database Conn=cx_oracle.connect (' Scott/[email protected]/orcl ') cur=conn.cursor () #执行语句cur. Prepare (' SELECT * from emp where empno = To_number (: id) ') # Take the entered employee number Empnum=input ("Please data Your work number:") #传递绑定变量到对应的语句cur. Execute (None, {' id ': empnum}) #将所有选定的行放入到resres = Cur.fetchall () # Iterate prints out the contents of the query for R in Res:print ("Name:" +str (r[1]) + "work Number:" +str (r[0]) + "Salary:" +str (r[5]) + "Monthly bonus:" +str (r[6)) + "") Cur.close () conn . Close ()
650) this.width=650; "title=" 5.png "src=" Http://s3.51cto.com/wyfs02/M01/59/AF/wKioL1TcKwuTcTptAAEEpqi5-SE271.jpg " alt= "Wkiol1tckwutctptaaeepqi5-se271.jpg"/>
to the corresponding directory, the data Python querysal.py, you can get the information you want to see.
The above is just a simple query of how much the salary of the function, inside did not add any error control content. will be perfected later
Python Link Oracle Learning