文档章节

cx_Oracle - Python Interface for Oracle Database

rootliu
 rootliu
发布于 2017/09/09 13:35
字数 744
阅读 15
收藏 0

cx_Oracle - Python Interface for Oracle Database

Documentation · Installation . Release Notes . Source code · Mailing list

cx_Oracle logo

About cx_Oracle

cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database API 2.0 specification with a considerable number of additions and a couple of exclusions.

cx_Oracle is licensed under a BSD license which you can find here.

cx_Oracle 6 has been tested with Python version 2.7, and with versions 3.4 and higher. You can use cx_Oracle with Oracle 11.2, 12.1 and 12.2 client libraries. Oracle's standard client-server version interoperability allows connection to both older and newer databases. For example Oracle 12.2 client libraries can connect to Oracle Database 11.2 or later.

Features

  • Easily installed from PyPI.

  • Support for Python 2 and 3.

  • Support for Oracle Client 11.2, 12.1 and 12.2. Oracle's standard cross-version interoperability, allows easy upgrades and connectivity to different Oracle Database versions.

  • Connect to Oracle Database 9.2, 10, 11 or 12 (depending on the Oracle Client version used).

  • SQL and PL/SQL Execution. The underlying Oracle Client libraries have significant optimizations including compressed fetch, pre-fetching, client and server result set caching, and statement caching with auto-tuning.

  • Full use of Oracle Network Service infrastructure, including encrypted network traffic and security features.

  • Extensive Oracle data type support, including large object support (CLOB and BLOB).

  • Direct binding to SQL objects. One great use case is binding Python objects to Oracle Spatial SDO objects.

  • Array operations for efficient INSERT and UPDATEs.

  • Array row counts and batch error handling for array operations.

  • Fetching of large result sets.

  • REF CURSOR support.

  • Support for scrollable cursors. Go back and forth through your query results.

  • Fetch PL/SQL Implicit Results. Easily return query results from PL/SQL.

  • Row Prefetching. Efficient use of the network.

  • Client Result Caching. Improve performance of frequently executed look-up statements.

  • Support for Advanced Queuing. Use database notifications to build micro-service applications.

  • Continuous Query Notification. Get notified when data changes.

  • Support for Edition Based Redefinition. Easily switch applications to use updated PL/SQL logic.

  • Support for setting application context during the creation of a connection, making application metadata more accessible to the database, including in LOGON triggers.

  • End-to-end monitoring and tracing.

  • Transaction Management.

  • Session Pooling.

  • Database Resident Connection Pooling (DRCP).

  • Privileged Connections.

  • External Authentication.

  • Database startup and shutdown.

  • Oracle Database High Availability Features, such as FAN notifications and Transaction Guard support.

DB API specification exclusions: The time data type is not supported by Oracle and is therefore not implemented. The methodcursor.nextset() is not implemented either as the DB API specification assumes an implementation of cursors that does not fit well with Oracle's implementation of cursors and implicit results. See the method cursor.getimplicitresults() for more information.

Installation

See cx_Oracle Installation for detailed instructions.

  • The simplest way to install cx_Oracle is with pip:

    python -m pip install cx_Oracle --upgrade

    If a binary wheel package is not available on PyPI for your platform, the source package will be used.

    Note that if you download a source zip file directly from GitHub then you will also need to download an ODPI-C source zip file and extract it inside the directory called "odpi".

  • After cx_Oracle is installed, Oracle client libraries must also be installed and configured. These can be from Oracle Instant Client, from a local Oracle Database, or from a full Oracle Client installation.

    If you need the libraries, download and unzip the Oracle Instant Client 'Basic' package for your platform and set PATH, LD_LIBRARY_PATH, or similar platform-specific library path loading environment. See the installation notes for ODPI-Cfor help.

    Versions 11.2, 12.1 and 12.2 of the Oracle Client libraries on Linux, Windows and macOS are supported. Users have also reported success with other platforms.

If you require cx_Oracle 5.3, download a Windows installer from PyPI or use python -m pip install cx-oracle==5.3 to install from source.

Very old versions of cx_Oracle can be found in the files section at Sourceforge.

Example

from __future__ import print_function

    import cx_Oracle

    connection = cx_Oracle.connect("hr", "welcome", "localhost/orclpdb")

    cursor = connection.cursor()
    cursor.execute("""
	    SELECT first_name, last_name
	    FROM employees
	    WHERE department_id = :did AND employee_id > :eid""",
	    did = 50,
	    eid = 190)
    for fname, lname in cursor:
	print("Values:", fname, lname)

For more examples, please see the samples and the test suite. You can also look at the scripts in cx_OracleTools and the modules in cx_PyOracleLib.

Documentation

See the cx_Oracle Documentation and Release Notes.

Help

Issues and questions can be raised with the cx_Oracle community on GitHub or on the mailing list.

本文转载自:https://oracle.github.io/python-cx_Oracle/index.html

共有 人打赏支持
rootliu
粉丝 4
博文 280
码字总数 2796
作品 0
海淀
数据库管理员
私信 提问
windows下安装cx_Oracle的方法

Install cx_Oracle Use Python’s Pip package to install cxOracle from PyPI: python -m pip install cx_Oracle --upgrade This will download and install a pre-compiled binary if one ......

良言
07/09
0
0
cx_Oracle 5.0.4 发布

cx_Oracle 是一个用来连接并操作 Oracle 数据库的 Python 扩展模块, 支持包括 Oracle 9.2 10.2 以及 11.1 等版本。 Changes: 1. adds support for Python 2.7 and adds support for specify......

红薯
2010/07/21
988
0
Python远程连接服务器上的Oracle数据库

Python远程连接服务器上的Oracle数据库 1、正确的开启方式 在你的IPython或者是Anaconda的jupyter中输入一下代码,其中: ‘username’—— 用户名 ‘password’——密码 ‘192.168.1.1:1521/...

推荐码发放
05/04
0
0
Linux cx-Oracle安装

问题 使用python2.7连接oracle 10g数据库,执行增删改查操作。 使用的linux主机上已安装oracle客户端。如果没有安装,还需提前安装…… 方案 使用包: 查看oracle版本: 下载对应版本的安装包...

莫显辉
2017/11/08
0
0
mac上安装python3的cx_Oracle数据库驱动

问题 使用Python3 for mac上面的cx_Oracle数据库驱动 步骤 下载Oracle的Instant Client 程序包 Instant Client 下载适用于 Mac OS X (Intel x86) 这里版本的选择,应该根据你访问的oracle库的...

亚林瓜子
08/03
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Range Sum Query - Immutable(leetcode303)

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRa......

woshixin
13分钟前
0
0
「阿里面试系列」面试加分项,从jvm层面了解线程的启动和停止

线程的启动的实现原理 线程停止的实现原理分析 为什么中断线程会抛出InterruptedException 线程的启动原理 前面我们简单分析过了线程的使用,通过调用线程的start方法来启动线程,线程启动后...

James-
20分钟前
0
0
转换 bytes 为 kb/mb/gb/tb/pb…

智能转换 bytes 为 kb/mb/gb/tb/pb… 用到了 math 模块中的一些函数 #!/usr/bin/env python# -*- coding: utf-8 -*-"""智能转换 bytes 为 kb/mb/gb/tb/pb..."""import mathdef conv...

郭恩洲_OSC博客
27分钟前
3
0
Mysql导出sql语句的方法及可能遇到的mysqldump: command not found

解决办法: 打开terminal    输入vi ~/.bash_profile    添加如下三行代码:    #mysql  PATH=$PATH:/usr/local/mysql/bin  export    保存并退出...

Liens
28分钟前
1
0
一文读懂,深入浅出 RPC框架

RPC 功能目标 RPC 的主要功能目标是让构建分布式计算(应用)更容易,在提供强大的远程调用能力时不损失本地调用的语义简洁性。为实现该目标,RPC 框架需提供一种透明调用机制让使用者不必显...

别打我会飞
29分钟前
8
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部