Python + cx_Orcale connect to Oracle databases

This is a problem I encountered when using python to connect to Oracle databases. In this summary do something.

1.pip install cx_Oracle



 

2. Then instantclient-basic need to download a database client tools

After decompression, add the path to the path variable system. Then restart Pycharm.

Download: https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html



 

3. Open the E: \ app \ Current user \ product \ 11.2.0 \ dbhome_1 \ tnsname.ora file under NETWORK \ ADMIN directory, check the configuration you want to connect to the database. If you do not need to add now, you can fill in their own Baidu specific format



 

4. The transmission database connection parameters as follows:

 

 

 Note: service_name here does not refer to this , but to make their own database executes the statement:

select value from v$parameter where name like '%service_name%'。查看service_name

 

 

5. check out the results of the general Chinese garbled happens.

If so, you need to add some statement on transcode before connecting to the database

 

 



 

6. After you can successfully query the data in an Oracle database

Guess you like

Origin www.cnblogs.com/Super-Treasure/p/12069234.html