python连接oracle数据库的新模块
从原来的cx_Oralce更新为oracldb
cx_Oracle has a major new release under a new name and homepagepython-oracledb.
New projects should install python-oracledb instead of cx_Oracle.
https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html
https://python-oracledb.readthedocs.io/en/latest/user_guide/appendix_c.html#upgrading83
使用方法:
import oracledb
You
must replace positional parameters with keyword parameters, unlessonly one parameter is being passed. Python-oracledb uses keyword parametersexclusively unless a DSN containing the user, password, and connect stringcombined, for example un/pw@cs, is used. This change makes the drivercompliant with the Python Database API specification
PEP 249.
For example, the following code will fail:
c = oracledb.connect("un", "pw", "cs")
and needs to be changed to:
c = oracledb.connect(user="un", password="pw", dsn="cs")
The following example will continue to work without change:
c = oracledb.connect("un/pw@cs")
eg:
c=oracledb.connect('user/pwd@192.168.1.1:1521/your_db_name')