Use python to query Oracle database

Need to use the library: cx_Oracle

Use pip to install

pip install cx_Oracle

After completing the installation of cx_Oracle, you can almost operate Oracle according to the idea of connecting MySQL.

import cx_Oracle

conn = cx_Oracle.connect('user','passwd','ipadress')
cursor = conn.cursor()
sql ='select * from test_table'
cursor.execute(sql)
res = cursor.fetchall()

The above is the simplest example, but there are a few points to note.

The idea of using python to operate major databases is very simple and clear. The main content of each third-party library connected to the database is to realize the communication with each database server. What we need is to completely send the sql statement to the server, and then the server will return the queried data to the local, and then we can directly use the obtained data.

Whether python connects to MySQL or python connects to Oracle, the essence is the same. What we need is a tool that can talk to the database server, and other parts can be treated as normal data operations.

For example, the above four lines of code can complete all operations on the database without using other library functions.

Recommended Posts

Use python to query Oracle database
Dry goods | Use Python to operate mysql database
How to use python tuples
How to use python thread pool
Use C++ to write Python3 extensions
Use python to achieve stepwise regression
How to use SQLite in Python
How to use and and or in Python
Use Python to make airplane war games
How to use PYTHON to crawl news articles
Python | So collections are so easy to use! !
Use Python to generate Douyin character videos!
Python novice learns to use the library
Use Python to quickly cut out images
Use python3 to install third on ubuntu
01. Introduction to Python
Python crawler-beautifulsoup use
Introduction to Python
How to use the round function in python
How to use the zip function in Python
How to use the format function in python
How to use code running assistant in python
Use python to realize business card management system
Use python to realize the aircraft war game
Centos 6.4 python 2.6 upgrade to 2.7
Centos 6.4 python 2.6 upgrade to 2.7
Python3 external module use
Python operation SQLite database
Centos default python2.6 upgrade to
Solution to python alignment error
CentOS upgrade python2 to pyth
Python code to find bugs(7)
Python code to find bugs(4)
Python code to find bugs (3)
Python code to find bugs(9)
How to learn python quickly
How to uninstall python plugin
Introduction to Python related modules
What databases can python use
Python code to find bugs(6)
Python code to find bugs (1)
Python code to find bugs(8)
3 ways to encrypt Python files
How to understand python objects
Python code to find bugs(5)
Use virtualbox to deploy ubuntu