Welcome to python-oracledb’s documentation
The python-oracledb driver is an open source Python module that enables access to Oracle Database. Python-oracledb is the renamed, major version successor to cx_Oracle 8.3. The cx_Oracle driver is obsolete and should not be used for new development.
You can use assistive technology products, such as screen readers, while you work with the python-oracledb documentation. You can also use the keyboard instead of the mouse.
User Guide
- 1. Introduction to the Python Driver for Oracle Database
- 2. Installing python-oracledb
- 2.1. Quick Start python-oracledb Installation
- 2.2. Supported Oracle Database Versions
- 2.3. Installation Requirements
- 2.4. Installing python-oracledb on Linux
- 2.5. Installing python-oracledb on Windows
- 2.6. Installing python-oracledb on macOS
- 2.7. Installing python-oracledb without Internet Access
- 2.8. Installing python-oracledb without the Cryptography Package
- 2.9. Installing from Source Code
- 2.10. Installing Centralized Configuration Provider Modules for python-oracledb
- 2.11. Installing Cloud Native Authentication Modules for python-oracledb
- 3. Initializing python-oracledb
- 3.1. Enabling python-oracledb Thick mode
- 3.2. Explicitly Enabling python-oracledb Thin Mode
- 3.3. Optional Oracle Configuration Files
- 3.4. Oracle Environment Variables for python-oracledb
- 3.5. Other python-oracledb Thick Mode Initialization
- 3.6. Migrating from python-oracledb Thick Mode to python-oracledb Thin Mode
- 4. Connecting to Oracle Database
- 4.1. Standalone Connections
- 4.2. Oracle Net Services Connection Strings
- 4.2.1. Easy Connect Syntax for Connection Strings
- 4.2.2. Connect Descriptors
- 4.2.3. TNS Aliases for Connection Strings
- 4.2.4. LDAP URL Connection Strings
- 4.2.5. Centralized Configuration Provider URL Connection Strings
- 4.2.6. JDBC and Oracle SQL Developer Connection Strings
- 4.2.7. Oracle Net Connect Descriptor and Easy Connect Keywords
- 4.2.8. Python-oracledb Parameters Settable in Easy Connect Strings or Central Configuration Providers
- 4.3. Centralized Configuration Providers
- 4.4. Using the ConnectParams Builder Class
- 4.5. Connection Hook Functions
- 4.6. LDAP Directory Naming
- 4.7. Connection Metadata and Application Contexts
- 4.8. Connection Pooling
- 4.8.1. Creating a Connection Pool
- 4.8.2. Using the Connection Pool Cache
- 4.8.3. Connection Pool Sizing
- 4.8.4. Pool Connection Health
- 4.8.5. Connection Pool Reconfiguration
- 4.8.6. Session Callbacks for Setting Pooled Connection State
- 4.8.7. Heterogeneous and Homogeneous Connection Pools
- 4.8.8. Using the PoolParams Builder Class
- 4.9. Database Resident Connection Pooling (DRCP)
- 4.10. Implicit Connection Pooling
- 4.11. Connecting Using Proxy Authentication
- 4.12. Connecting Using External Authentication
- 4.13. Token-Based Authentication
- 4.14. Privileged Connections
- 4.15. Securely Encrypting Network Traffic to Oracle Database
- 4.16. Resetting Passwords
- 4.17. Connecting to Oracle Cloud Autonomous Databases
- 4.18. Connecting Through a Firewall via a Proxy
- 4.19. Connecting using Multiple Wallets
- 4.20. Connecting to Oracle Globally Distributed Database
- 5. Executing SQL
- 5.1. SQL Queries
- 5.1.1. Fetch Methods
- 5.1.2. Closing Cursors
- 5.1.3. Query Column Metadata
- 5.1.4. Fetch Data Types
- 5.1.5. Changing Fetched Data
- 5.1.6. Fetched Number Precision
- 5.1.7. Scrollable Cursors
- 5.1.8. Fetching Oracle Database Objects and Collections
- 5.1.9. Fetching Data Frames
- 5.1.10. Limiting Rows
- 5.1.11. Fetching Data in Parallel
- 5.1.12. Fetching Raw Data
- 5.1.13. Querying Corrupt Data
- 5.2. INSERT and UPDATE Statements
- 5.1. SQL Queries
- 6. Executing PL/SQL
- 7. Using Bind Variables
- 7.1. Binding by Name or Position
- 7.2. Bind Direction
- 7.3. Binding Null Values
- 7.4. Binding ROWID Values
- 7.5. Binding UROWID Values
- 7.6. DML RETURNING Bind Variables
- 7.7. LOB Bind Variables
- 7.8. REF CURSOR Bind Variables
- 7.9. Binding PL/SQL Collections
- 7.10. Binding PL/SQL Records
- 7.11. Binding Spatial Data Types
- 7.12. Reducing the SQL Version Count
- 7.13. Changing Bind Data Types using an Input Type Handler
- 7.14. Binding Multiple Values to a SQL WHERE IN Clause
- 7.15. Binding Column and Table Names
- 8. Executing Batch Statements and Bulk Loading
- 9. Managing Transactions
- 10. Tuning python-oracledb
- 11. Using CLOB, BLOB, NCLOB, and BFILE Data
- 12. Using JSON Data
- 13. Using XMLTYPE Data
- 14. Using VECTOR Data
- 15. Working with Simple Oracle Document Access (SODA)
- 16. Using Oracle Transactional Event Queues and Advanced Queuing
- 17. Working with Continuous Query Notification (CQN)
- 18. Using Two-Phase Commits (TPC)
- 19. Starting and Stopping Oracle Database
- 20. Using High Availability with python-oracledb
- 21. Character Sets and Globalization
- 22. Concurrent Programming with asyncio and Pipelining
- 23. Catching Exceptions
- 24. Tracing python-oracledb
- 25. Extending python-oracledb
- 26. Troubleshooting Errors
- 27. Appendix A: Oracle Database Features Supported by python-oracledb
- 28. Appendix B: Differences between python-oracledb Thin and Thick Modes
- 28.1. Connection Handling Differences between Thin and Thick Modes
- 28.2. Connection Pooling Differences between Thin and Thick Modes
- 28.3. Supported Database Data Types in Thin and Thick Modes
- 28.4. Query Metadata in Thin and Thick Modes
- 28.5. Implicit Results in Thin and Thick Modes
- 28.6. Statement Caching in Thin and Thick Modes
- 28.7. Error Handling in Thin and Thick Modes
- 28.8. Globalization in Thin and Thick Modes
- 28.9. Tracing in Thin and Thick Modes
- 29. Appendix C: The python-oracledb and cx_Oracle Drivers
- 29.1. Differences between the python-oracledb and cx_Oracle Drivers
- 29.1.1. Mode differences from cx_Oracle
- 29.1.2. Oracle Client Library Loading Differences from cx_Oracle
- 29.1.3. Connection Differences from cx_Oracle
- 29.1.4. Pooling Differences from cx_Oracle
- 29.1.5. Cursor Object Differences from cx_Oracle
- 29.1.6. Fetching IS JSON Column Differences from cx_Oracle
- 29.1.7. Advanced Queuing (AQ) Differences from cx_Oracle
- 29.1.8. Error Handling Differences from cx_Oracle
- 29.2. Upgrading from cx_Oracle 8.3 to python-oracledb
- 29.1. Differences between the python-oracledb and cx_Oracle Drivers
API Manual
- 1. API: python-oracledb Module
- 1.1. Oracledb Methods
Binary()clientversion()connect()connect_async()ConnectParams()create_pipeline()create_pool()create_pool_async()Cursor()Date()DateFromTicks()enable_thin_mode()get_pool()init_oracle_client()is_thin_mode()makedsn()PoolParams()SparseVector()register_params_hook()register_password_type()register_protocol()Time()TimeFromTicks()Timestamp()TimestampFromTicks()unregister_params_hook()
- 1.2. Oracledb IntervalYM Class
- 1.3. Oracledb JsonId Class
- 1.4. Oracledb __future__ Object
- 1.5. Oracledb Constants
- 1.5.1. General
- 1.5.2. Advanced Queuing: Delivery Modes
- 1.5.3. Advanced Queuing: Dequeue Modes
- 1.5.4. Advanced Queuing: Dequeue Navigation Modes
- 1.5.5. Advanced Queuing: Dequeue Visibility Modes
- 1.5.6. Advanced Queuing: Dequeue Wait Modes
- 1.5.7. Advanced Queuing: Enqueue Visibility Modes
- 1.5.8. Advanced Queuing: Message States
- 1.5.9. Advanced Queuing: Other Constants
- 1.5.10. Connection Authorization Modes
- 1.5.11. Pipeline Operation Types
- 1.5.12. Database Shutdown Modes
- 1.5.13. Event Types
- 1.5.14. Operation Codes
- 1.5.15. Connection Pool Get Modes
- 1.5.16. Connection Pool Purity Constants
- 1.5.17. Subscription Grouping Classes
- 1.5.18. Subscription Grouping Types
- 1.5.19. Subscription Namespaces
- 1.5.20. Subscription Protocols
- 1.5.21. Subscription Quality of Service
- 1.5.22. DB API Types
- 1.5.23. Database Types
- 1.5.24. Database Type Synonyms
- 1.5.25. Other Types
- 1.5.26. Two-Phase Commit (TPC) Constants
- 1.5.27. Vector Format Constants
- 1.6. Oracledb Exceptions
- 1.7. Oracledb _Error Objects
- 1.8. Oracledb Plugins
- 1.1. Oracledb Methods
- 2. API: Defaults Object
- 3. API: Connection Objects
- 3.1. Connection Methods
Connection.__enter__()Connection.__exit__()Connection.begin()Connection.cancel()Connection.changepassword()Connection.close()Connection.commit()Connection.createlob()Connection.cursor()Connection.decode_oson()Connection.encode_oson()Connection.fetch_df_all()Connection.fetch_df_batches()Connection.getSodaDatabase()Connection.gettype()Connection.is_healthy()Connection.msgproperties()Connection.ping()Connection.prepare()Connection.queue()Connection.rollback()Connection.shutdown()Connection.startup()Connection.subscribe()Connection.tpc_begin()Connection.tpc_commit()Connection.tpc_end()Connection.tpc_forget()Connection.tpc_prepare()Connection.tpc_recover()Connection.tpc_rollback()Connection.unsubscribe()Connection.xid()
- 3.2. Connection Attributes
Connection.actionConnection.autocommitConnection.call_timeoutConnection.client_identifierConnection.clientinfoConnection.current_schemaConnection.db_domainConnection.db_nameConnection.dbopConnection.dsnConnection.econtext_idConnection.editionConnection.external_nameConnection.handleConnection.inputtypehandlerConnection.instance_nameConnection.internal_nameConnection.ltxidConnection.max_identifier_lengthConnection.max_open_cursorsConnection.moduleConnection.outputtypehandlerConnection.proxy_userConnection.sduConnection.serial_numConnection.service_nameConnection.session_idConnection.stmtcachesizeConnection.tagConnection.thinConnection.transaction_in_progressConnection.usernameConnection.versionConnection.warning
- 3.1. Connection Methods
- 4. API: ConnectParams Objects
- 4.1. ConnectParams Methods
- 4.2. ConnectParams Attributes
ConnectParams.appcontextConnectParams.cclassConnectParams.config_dirConnectParams.connection_id_prefixConnectParams.debug_jdwpConnectParams.disable_oobConnectParams.driver_nameConnectParams.editionConnectParams.eventsConnectParams.expire_timeConnectParams.externalauthConnectParams.extra_auth_paramsConnectParams.hostConnectParams.https_proxyConnectParams.https_proxy_portConnectParams.instance_nameConnectParams.machineConnectParams.matchanytagConnectParams.modeConnectParams.osuserConnectParams.pool_boundaryConnectParams.portConnectParams.programConnectParams.protocolConnectParams.proxy_userConnectParams.purityConnectParams.retry_countConnectParams.retry_delayConnectParams.sduConnectParams.server_typeConnectParams.service_nameConnectParams.shardingkeyConnectParams.sidConnectParams.ssl_contextConnectParams.ssl_server_cert_dnConnectParams.ssl_server_dn_matchConnectParams.ssl_versionConnectParams.stmtcachesizeConnectParams.supershardingkeyConnectParams.tagConnectParams.tcp_connect_timeoutConnectParams.use_sniConnectParams.terminalConnectParams.thick_mode_dsn_passthroughConnectParams.use_tcp_fast_openConnectParams.userConnectParams.wallet_location
- 5. API: ConnectionPool Objects
- 5.1. ConnectionPool Methods
- 5.2. ConnectionPool Attributes
ConnectionPool.busyConnectionPool.dsnConnectionPool.getmodeConnectionPool.homogeneousConnectionPool.incrementConnectionPool.maxConnectionPool.max_lifetime_sessionConnectionPool.max_sessions_per_shardConnectionPool.minConnectionPool.nameConnectionPool.openedConnectionPool.ping_intervalConnectionPool.soda_metadata_cacheConnectionPool.stmtcachesizeConnectionPool.thinConnectionPool.timeoutConnectionPool.usernameConnectionPool.wait_timeout
- 6. API: PoolParams Objects
- 6.1. PoolParams Methods
- 6.2. PoolParams Attributes
PoolParams.connectiontypePoolParams.getmodePoolParams.homogeneousPoolParams.incrementPoolParams.minPoolParams.maxPoolParams.max_lifetime_sessionPoolParams.max_sessions_per_shardPoolParams.ping_intervalPoolParams.ping_timeoutPoolParams.session_callbackPoolParams.soda_metadata_cachePoolParams.timeoutPoolParams.wait_timeout
- 7. API: Cursor Objects
- 7.1. Cursor Methods
Cursor.__enter__()Cursor.__exit__()Cursor.__iter__()Cursor.arrayvar()Cursor.bindnames()Cursor.callfunc()Cursor.callproc()Cursor.close()Cursor.execute()Cursor.executemany()Cursor.fetchall()Cursor.fetchmany()Cursor.fetchone()Cursor.getarraydmlrowcounts()Cursor.getbatcherrors()Cursor.getimplicitresults()Cursor.parse()Cursor.prepare()Cursor.scroll()Cursor.setinputsizes()Cursor.setoutputsize()Cursor.var()
- 7.2. Cursor Attributes
- 7.1. Cursor Methods
- 8. API: Data Frames
- 9. API: FetchInfo Objects
- 9.1. FetchInfo Attributes
FetchInfo.annotationsFetchInfo.display_sizeFetchInfo.domain_nameFetchInfo.domain_schemaFetchInfo.internal_sizeFetchInfo.is_jsonFetchInfo.is_osonFetchInfo.nameFetchInfo.null_okFetchInfo.precisionFetchInfo.scaleFetchInfo.typeFetchInfo.type_codeFetchInfo.vector_dimensionsFetchInfo.vector_formatFetchInfo.vector_is_sparse
- 9.1. FetchInfo Attributes
- 10. API: Variable Objects
- 11. API: Subscription Objects
- 11.1. Subscription Methods
- 11.2. Subscription Attributes
Subscription.callbackSubscription.connectionSubscription.idSubscription.ip_addressSubscription.nameSubscription.namespaceSubscription.operationsSubscription.portSubscription.protocolSubscription.qosSubscription.timeout- 11.2.1. Message Objects
- 11.2.2. MessageTable Objects
- 11.2.3. MessageRow Objects
- 11.2.4. MessageQuery Objects
- 12. API: LOB Objects
- 13. API: DbObjectType Objects
- 14. API: SparseVector Objects
- 15. API: Advanced Queuing (AQ)
- 15.1. Queue Objects
- 15.2. Dequeue Options
- 15.3. Enqueue Options
- 15.4. Message Properties
MessageProperties.attemptsMessageProperties.correlationMessageProperties.delayMessageProperties.deliverymodeMessageProperties.enqtimeMessageProperties.exceptionqMessageProperties.expirationMessageProperties.msgidMessageProperties.payloadMessageProperties.priorityMessageProperties.stateMessageProperties.recipients
- 16. API: SODA
- 17. API: AsyncConnection Objects
- 17.1. AsyncConnection Methods
AsyncConnection.__aenter__()AsyncConnection.__aexit__()AsyncConnection.callfunc()AsyncConnection.callproc()AsyncConnection.cancel()AsyncConnection.changepassword()AsyncConnection.close()AsyncConnection.commit()AsyncConnection.createlob()AsyncConnection.cursor()AsyncConnection.decode_oson()AsyncConnection.encode_oson()AsyncConnection.execute()AsyncConnection.executemany()AsyncConnection.fetch_df_all()AsyncConnection.fetch_df_batches()AsyncConnection.fetchall()AsyncConnection.fetchmany()AsyncConnection.fetchone()AsyncConnection.gettype()AsyncConnection.is_healthy()AsyncConnection.msgproperties()AsyncConnection.ping()AsyncConnection.queue()AsyncConnection.rollback()AsyncConnection.run_pipeline()AsyncConnection.tpc_begin()AsyncConnection.tpc_commit()AsyncConnection.tpc_end()AsyncConnection.tpc_forget()AsyncConnection.tpc_prepare()AsyncConnection.tpc_recover()AsyncConnection.tpc_rollback()
- 17.2. AsyncConnection Attributes
AsyncConnection.actionAsyncConnection.autocommitAsyncConnection.call_timeoutAsyncConnection.client_identifierAsyncConnection.clientinfoAsyncConnection.current_schemaAsyncConnection.db_domainAsyncConnection.db_nameAsyncConnection.dbopAsyncConnection.dsnAsyncConnection.econtext_idAsyncConnection.editionAsyncConnection.external_nameAsyncConnection.inputtypehandlerAsyncConnection.instance_nameAsyncConnection.internal_nameAsyncConnection.ltxidAsyncConnection.max_identifier_lengthAsyncConnection.max_open_cursorsAsyncConnection.moduleAsyncConnection.outputtypehandlerAsyncConnection.sduAsyncConnection.serial_numAsyncConnection.service_nameAsyncConnection.session_idAsyncConnection.stmtcachesizeAsyncConnection.thinAsyncConnection.transaction_in_progressAsyncConnection.usernameAsyncConnection.version
- 17.1. AsyncConnection Methods
- 18. API: AsyncConnectionPool Objects
- 18.1. AsyncConnectionPool Methods
- 18.2. AsyncConnectionPool Attributes
AsyncConnectionPool.busyAsyncConnectionPool.dsnAsyncConnectionPool.getmodeAsyncConnectionPool.homogeneousAsyncConnectionPool.incrementAsyncConnectionPool.maxAsyncConnectionPool.max_lifetime_sessionAsyncConnectionPool.max_sessions_per_shardAsyncConnectionPool.minAsyncConnectionPool.nameAsyncConnectionPool.openedAsyncConnectionPool.ping_intervalAsyncConnectionPool.soda_metadata_cacheAsyncConnectionPool.stmtcachesizeAsyncConnectionPool.thinAsyncConnectionPool.timeoutAsyncConnectionPool.usernameAsyncConnectionPool.wait_timeout
- 19. API: AsyncCursor Objects
- 19.1. AsyncCursor Methods
AsyncCursor.__aiter__()AsyncCursor.__enter__()AsyncCursor.__exit__()AsyncCursor.arrayvar()AsyncCursor.bindnames()AsyncCursor.callfunc()AsyncCursor.callproc()AsyncCursor.close()AsyncCursor.execute()AsyncCursor.executemany()AsyncCursor.fetchall()AsyncCursor.fetchmany()AsyncCursor.fetchone()AsyncCursor.getarraydmlrowcounts()AsyncCursor.getbatcherrors()AsyncCursor.getimplicitresults()AsyncCursor.parse()AsyncCursor.prepare()AsyncCursor.setinputsizes()AsyncCursor.scroll()AsyncCursor.setoutputsize()AsyncCursor.var()
- 19.2. AsyncCursor Attributes
- 19.1. AsyncCursor Methods
- 20. API: AsyncLOB Objects
- 21. API: Async Advanced Queuing (AQ)
- 22. API: Pipeline Objects
- 23. Deprecated and Desupported Features