### PL/SQL Setup for Spatial Data Example Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/plsql_execution.html Creates a table and a PL/SQL function to retrieve spatial point data. This setup is required before calling the function from Python. ```plsql create table MyPoints ( id number(9) not null, point sdo_point_type not null ); insert into MyPoints values (1, sdo_point_type(125, 375, 0)); create or replace function spatial_queryfn ( a_Id number ) return sdo_point_type is t_Result sdo_point_type; begin select point into t_Result from MyPoints where Id = a_Id; return t_Result; end; / ``` -------------------------------- ### Search Documents with Query-by-Example Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/soda.html Illustrates how to search for documents within a SODA collection using the query-by-example (QBE) syntax. This example finds all documents where the 'name' field starts with 'Ma%' and prints the names of the matching documents. ```python # Find all documents with names like 'Ma%' print("Names matching 'Ma%'") qbe = {'name': {'$like': 'Ma%'}} for doc in collection.find().filter(qbe).getDocuments(): content = doc.getContent() print(content["name"]) ``` -------------------------------- ### Run Instant Client installation script on macOS ARM64 Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Execute the install script from the mounted Instant Client DMG. This script installs the Oracle Client libraries. ```bash /Volumes/instantclient-basic-macos.arm64-23.3.0.23.09/install_ic.sh ``` -------------------------------- ### Manual Instant Client Installation on macOS Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs Oracle Instant Client on macOS Intel x86-64 by manually mounting the DMG and running the install script. The Instant Client will be located in `$HOME/Downloads/instantclient_19_16`. ```bash /Volumes/instantclient-basic-macos.x64-19.16.0.0.0dbru/install_ic.sh ``` -------------------------------- ### Start Database Service Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/ha.html Start the newly created database service using DBMS_SERVICE.START_SERVICE. This command should be executed as SYSDBA. ```plsql BEGIN DBMS_SERVICE.START_SERVICE(''); END; / ``` -------------------------------- ### Create and Start AQ Queue Table and Queue Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/aq.html Creates an AQ queue table for the UDT_BOOK object type and then creates and starts a queue using that table. ```sql begin dbms_aqadm.create_queue_table('BOOK_QUEUE_TAB', 'UDT_BOOK'); dbms_aqadm.create_queue('DEMO_BOOK_QUEUE', 'BOOK_QUEUE_TAB'); dbms_aqadm.start_queue('DEMO_BOOK_QUEUE'); end; / ``` -------------------------------- ### Install Oracle Instant Client RPM on Linux Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the Oracle Instant Client Basic RPM package using dnf. Ensure you download the correct RPM for your system architecture. ```bash sudo dnf install oracle-instantclient-basic-23.9.0.25.07-1.el9.x86_64.rpm ``` -------------------------------- ### Install OpenTelemetry Modules Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/tracing.html Install the necessary OpenTelemetry modules for database API instrumentation. This includes the SDK, API, and the DBAPI instrumentation package. ```bash python -m pip install opentelemetry-sdk opentelemetry-api opentelemetry-instrumentation-dbapi ``` -------------------------------- ### Install python-oracledb with Proxy Configuration Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/troubleshooting.html Use this command to install python-oracledb when a network proxy is required. Specify your proxy server details to enable the installation process. ```python python -m pip install --proxy=http://proxy.example.com:80 oracledb --upgrade ``` -------------------------------- ### Install python-oracledb Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/appendix_c.html Use this command to install or upgrade the python-oracledb driver. This command can be used for both initial installation and subsequent upgrades. ```bash python -m pip install oracledb --upgrade ``` -------------------------------- ### Scripted Instant Client Installation on macOS Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Automates the download, mounting, and installation of Oracle Instant Client on macOS Intel x86-64. Ensure you use the latest DMG available. ```bash cd $HOME/Downloads curl -O https://download.oracle.com/otn_software/mac/instantclient/1916000/instantclient-basic-macos.x64-19.16.0.0.0dbru.dmg hdiutil mount instantclient-basic-macos.x64-19.16.0.0.0dbru.dmg /Volumes/instantclient-basic-macos.x64-19.16.0.0.0dbru/install_ic.sh hdiutil unmount /Volumes/instantclient-basic-macos.x64-19.16.0.0.0dbru ``` -------------------------------- ### Install python-oracledb with proxy support Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the python-oracledb package from PyPI when behind a proxy server. Specify the proxy URL and port. ```bash python -m pip install oracledb --upgrade --user --proxy=http://proxy.example.com:80 ``` -------------------------------- ### Example Connection Error with Prefix (Thin Mode) Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/tracing.html This shows an example of a connection error message in Thin mode, where the custom prefix 'MYAPP' is prepended to the CONNECTION_ID. ```text DPY-6005: cannot connect to database (CONNECTION_ID=MYAPPm0PfUY6hYSmWPcgrHZCQIQ==). ``` -------------------------------- ### Azure App Configuration Connection String Example Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html An example of a connection string URL used with the python-oracledb driver to connect via Azure App Configuration. This example includes authentication parameters for client ID and secret. ```python configazureurl = "config-azure://aznetnamingappconfig.azconfig.io/?key=test/&azure_client_id=123-456&azure_client_secret=MYSECRET&azure_tenant_id=789-123" ``` -------------------------------- ### Install libaio Package on Linux Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the libaio package, which is a dependency for Oracle Instant Client. The package name may vary across Linux distributions. ```bash sudo dnf install libaio ``` -------------------------------- ### Install OCI Cloud Native Authentication Modules Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Install the Python SDK for Oracle Cloud Infrastructure to use the OCI Cloud Native Authentication Plugin with python-oracledb. This command installs the `[oci_auth]` dependency. ```bash python -m pip install oracledb[oci_auth] ``` -------------------------------- ### NNE Enabled Example Output Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/troubleshooting.html Example output from `v$session_connect_info` indicating that Native Network Encryption and checksumming services are enabled. This output is relevant when troubleshooting DPY-3001 errors. ```text NETWORK_SERVICE_BANNER ------------------------------------------------------------------------------------- TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production Encryption service for Linux: Version 19.0.1.0.0 - Production AES256 Encryption service adapter for Linux: Version 19.0.1.0.0 - Production Crypto-checksumming service for Linux: Version 19.0.1.0.0 - Production SHA256 Crypto-checksumming service adapter for Linux: Version 19.0.1.0.0 - Production ``` -------------------------------- ### Example: Using End-User Security Context Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html Demonstrates setting and clearing an end-user security context on a connection. This example shows how to create a context payload, apply it to a connection, execute operations within the context, and then clear it for subsequent operations. ```python import oracledb import sys def get_token(filename): with open(filename, 'r', encoding='utf-8') as file: token = file.read().strip() return token # Read user and database tokens from files passed as command-line arguments user_token = get_token(sys.argv[1]) db_token = get_token(sys.argv[2]) # Define the name of the data roles data_roles = ["HCM_ROLE"] # Define the context attributes attrs = { "p1": 33, "p2": "test2" } ctx_attrs = { "HR.HCM": attrs } # Create an end-user security context payload context = oracledb.create_end_user_security_context( end_user_identity = user_token, database_access_token = db_token, data_roles = data_roles, attributes = ctx_attrs ) # Create a standalone connection connection = oracledb.connect(user="db_user", password=userpwd, dsn="orclpdb", config_dir="/opt/oracle/config", wallet_location="location_of_pem_file", wallet_password=walletpw) # Set the end-user security context payload on a connection connection.set_end_user_security_context(context) # Execute a database operation within the end user security context with connection.cursor() as cursor: cursor.execute("select 1 from dual") row = cursor.fetchone() print(row) # Clear the end-user security context payload # Subsequent database operations run without the end user security context connection.clear_end_user_security_context() # Execute a database operation without the end user security context with connection.cursor() as cursor: cursor.execute("select 2 from dual") row = cursor.fetchone() print(row) # Close the connection connection.close() ``` -------------------------------- ### Manually install libnsl package Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the `libnsl` package on Linux systems, which may be required for Oracle Instant Client 19 or later to make `libnsl.so` available. ```bash sudo dnf install libnsl ``` -------------------------------- ### Install Oracle Instant Client 23 on Oracle Linux 8 Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the Oracle Instant Client release and basic package for Oracle Linux 8, supporting Oracle Database 26ai. Available for x86-64 and aarch64 architectures. ```bash sudo dnf install oracle-instantclient-release-26ai-el8 sudo dnf install oracle-instantclient-basic ``` -------------------------------- ### Install python-oracledb for system Python Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html To install into the system's Python environment, you may need to specify the full path to the python3 executable. ```bash /usr/bin/python3 -m pip install oracledb --upgrade --user ``` -------------------------------- ### Install Oracle Instant Client 23 on Oracle Linux 10 Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the Oracle Instant Client release and basic package for Oracle Linux 10, supporting Oracle Database 26ai. ```bash sudo dnf install oracle-instantclient-release-26ai-el10 sudo dnf install oracle-instantclient-basic ``` -------------------------------- ### Install python-oracledb Wheel Package Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs a pre-built python-oracledb wheel package from the local dist directory. Ensure the wheel file matches your architecture and Python version. ```bash python -m pip install dist/oracledb-4.0.0-cp314-cp314-macosx_14_0_arm64.whl ``` -------------------------------- ### Install Oracle Instant Client 23 on Oracle Linux 9 Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the Oracle Instant Client release and basic package for Oracle Linux 9, supporting Oracle Database 26ai. Available for x86-64 and aarch64 architectures. ```bash sudo dnf install oracle-instantclient-release-26ai-el9 sudo dnf install oracle-instantclient-basic ``` -------------------------------- ### Example SQL Tracing Output Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/tracing.html This is an example of the tracing output generated when DPI_DEBUG_LEVEL is set to 16. It includes thread identifiers, timestamps, and the SQL statement executed. ```text ODPI [23389068] 2025-06-25 12:07:55.405: ODPI-C 5.5.1 ODPI [23389068] 2025-06-25 12:07:55.405: debugging messages initialized at level 16 ODPI [23389068] 2025-06-25 12:08:01.363: SQL select name from jobs ``` -------------------------------- ### Install Oracle Instant Client 19 on Oracle Linux 8 Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the Oracle Instant Client release and basic package for Oracle Linux 8, supporting Oracle Database 19c. Available for x86-64 and aarch64 architectures. ```bash sudo dnf install -y oracle-release-el8 sudo dnf install -y oracle-instantclient19.XX-basic ``` -------------------------------- ### Install Oracle Instant Client 19 on Oracle Linux 9 Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the Oracle Instant Client release and basic package for Oracle Linux 9, supporting Oracle Database 19c. Available for x86-64 and aarch64 architectures. ```bash sudo dnf install oracle-instantclient-release-el9 sudo dnf install oracle-instantclient19.XX-basic ``` -------------------------------- ### NNE Disabled Example Output Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/troubleshooting.html Example output from `v$session_connect_info` indicating that Native Network Encryption and checksumming are not enabled. This output is relevant when troubleshooting DPY-3001 errors. ```text NETWORK_SERVICE_BANNER ------------------------------------------------------------------------------------- TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production Encryption service for Linux: Version 19.0.1.0.0 - Production ``` -------------------------------- ### Install python-oracledb using pip Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the python-oracledb package from PyPI. Use this command to get the latest version. The module name is 'oracledb'. ```bash python -m pip install oracledb --upgrade --user ``` -------------------------------- ### Connection.startup() Source: https://python-oracledb.readthedocs.io/en/latest/api_manual/connection.html Starts up the database, equivalent to 'startup nomount' in SQL*Plus. Requires connection as SYSDBA or SYSOPER with PRELIM_AUTH. An optional pfile can be specified. ```APIDOC ## Connection.startup() ### Description Starts up the database. This is equivalent to the SQL*Plus command `startup nomount`. The connection must be connected as `SYSDBA` or `SYSOPER` with the `PRELIM_AUTH` option specified for this to work. The `pfile` parameter, if specified, is expected to be a string identifying the location of the parameter file (PFILE) which will be used instead of the stored parameter file (SPFILE). See Starting and Stopping Oracle Database. _This method is an extension to the DB API definition._ ### Method ### Endpoint ### Parameters - **force** (bool) - Optional - If True, forces the startup. Defaults to False. - **restrict** (bool) - Optional - If True, starts the database in restricted mode. Defaults to False. - **pfile** (str | None) - Optional - The location of the parameter file (PFILE) to use. ### Request Example ### Response - **return value** (None) ``` -------------------------------- ### Download and mount Instant Client DMG on macOS ARM64 Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Download the Instant Client Basic DMG for macOS ARM64 and mount it. This is the first step for a scripted installation. ```bash cd $HOME/Downloads curl -O https://download.oracle.com/otn_software/mac/instantclient/233023/instantclient-basic-macos.arm64-23.3.0.23.09.dmg hdiutil mount instantclient-basic-macos.arm64-23.3.0.23.09.dmg ``` -------------------------------- ### Source Oracle environment script Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Sets required Oracle environment variables, such as `ORACLE_HOME`, by sourcing the Oracle environment script. Example for a generic installation. ```bash source /usr/local/bin/oraenv ``` -------------------------------- ### Initialize Oracle Client with Library and Configuration Directories Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html When using optional Oracle configuration files with Instant Client, specify both the library directory and the configuration directory using `lib_dir` and `config_dir` parameters. ```python import oracledb oracledb.init_oracle_client(lib_dir=r"C:\oracle\instantclient_23_26", config_dir=r"C:\oracle\your_config_dir") ``` -------------------------------- ### Get ConnectParams Host Attribute Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html Access individual connection parameter values stored in a ConnectParams object as attributes. For example, retrieve the host name using cp.host. ```python print(cp.host) ``` -------------------------------- ### OS Authentication Example Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/authentication_methods.html Connect to the database using operating system authentication. Ensure the DSN and any necessary authentication parameters are correctly configured. ```python connection = oracledb.connect( dsn=mydb_low, extra_auth_params=token_based_auth ) ``` -------------------------------- ### Query Duality View using SODA API Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/json_data_type.html Access the BookDV duality view directly using SODA NoSQL-style document APIs. This example demonstrates a query-by-example to find books with titles starting with 'The%'. ```python soda = connection.getSodaDatabase() collection = soda.openCollection('BOOKDV') qbe = {'book_title': {'$like': 'The%'}} for doc in collection.find().filter(qbe).getDocuments(): content = doc.getContent() print(content["book_title"]) ``` -------------------------------- ### Demonstrating Initial Script Output Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/cqn.html Shows the expected output when the CQN script is initially run before any database changes occur. ```text Hit enter to stop CQN demo ``` -------------------------------- ### Automate Symbolic Link Creation for Oracle Client Libraries on macOS Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/initialization.html This Python script automates the creation of a symbolic link for Oracle Client libraries on macOS, similar to the bash example. It dynamically determines the python-oracledb installation path. ```python CLIENT_DIR = "~/Downloads/instantclient_23_3" LIB_NAME = "libclntsh.dylib" import os import oracledb target_dir = oracledb.__path__[0] os.symlink(os.path.join(CLIENT_DIR, LIB_NAME), os.path.join(target_dir, LIB_NAME)) ``` -------------------------------- ### Install or Upgrade python-oracledb with User Installation Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/troubleshooting.html Use this command to install or upgrade python-oracledb when you lack permissions to modify the system Python installation. It installs the package in the user's home directory. ```python python -m pip install oracledb --upgrade --user ``` -------------------------------- ### Initialize Oracle Instant Client Libraries Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Loads the installed Oracle Instant Client libraries into your application. Specify the directory containing the Instant Client libraries. ```python import oracledb oracledb.init_oracle_client(lib_dir="/Users/your_username/Downloads/instantclient_23_3") ``` -------------------------------- ### Install python-oracledb on Offline Computer Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the python-oracledb wheel package on a computer without internet access. Ensure you also install the cryptography package and its dependencies separately. ```bash python -m pip install "" ``` -------------------------------- ### Basic Asyncio Pipelining Example Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/asyncio.html Demonstrates creating a pipeline, adding different types of query operations, executing it, and printing the results. Requires an active asyncio event loop and an OracleDB connection. ```python import asyncio import oracledb async def main(): # Create a pipeline and define the operations pipeline = oracledb.create_pipeline() pipeline.add_fetchone("select temperature from weather") pipeline.add_fetchall("select name from friends where active = true") pipeline.add_fetchmany("select story from news order by popularity", num_rows=5) connection = await oracle.connect_async(user="hr", password=userpwd, dsn="localhost/orclpdb") # Run the operations in the pipeline result_1, result_2, result_3 = await connection.run_pipeline(pipeline) # Print the database responses print("Current temperature:", result_1.rows) print("Active friends:", result_2.rows) print("Top news stories:", result_3.rows) await connection.close() asyncio.run(main()) ``` -------------------------------- ### Install python-oracledb without Cryptography Package Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs python-oracledb using pip's --no-deps option, allowing installation when the cryptography package is unavailable. Note that Thin mode will not be usable. ```bash python -m pip install oracledb --no-deps ``` -------------------------------- ### Install Azure Cloud Native Authentication Modules Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Install the Microsoft Authentication Library (MSAL) for Python to use the Azure Cloud Native Authentication Plugin with python-oracledb. This command installs the `[azure_auth]` dependency. ```bash python -m pip install oracledb[azure_auth] ``` -------------------------------- ### Configure Instant Client with External Files Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Initializes the Oracle Instant Client libraries and specifies a directory for external configuration files like tnsnames.ora. Alternatively, set the TNS_ADMIN environment variable. ```python import oracledb oracledb.init_oracle_client(lib_dir="/Users/your_username/Downloads/instantclient_23_3", config_dir="/Users/your_username/oracle/your_config_dir") ``` -------------------------------- ### Start Oracle Database Instance Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/startup.html Initiates the startup sequence for an Oracle Database instance. Requires a privileged connection in PRELIM_AUTH mode, followed by normal SYSDBA mode for mounting and opening the database. ```python # the connection must be in PRELIM_AUTH mode to perform startup connection = oracledb.connect(mode=oracledb.SYSDBA | oracledb.PRELIM_AUTH) connection.startup() # the following statements must be issued in normal SYSDBA mode connection = oracledb.connect(mode=oracledb.SYSDBA) cursor = connection.cursor() cursor.execute("alter database mount") cursor.execute("alter database open") ``` -------------------------------- ### Example JSON Fetch Output Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/json_data_type.html This is an example of the output when fetching a row containing JSON data. ```text (1, {'name': 'Sally', 'dept': 'Sales', 'location': 'France'}) ``` -------------------------------- ### Create a Connection Parameter Hook Plugin Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/extending.html This example shows how to log all connection creations by registering a parameter hook. This hook is called before connection or pool creation, allowing access to connection parameters. ```python import oracledb def my_params_hook(params: oracledb.ConnectParams): print(f"Connecting to the database as {params.user}") oracledb.register_params_hook(my_params_hook) ``` ```python connection = oracledb.connect(user="hr", password=userpwd, dsn="dbhost.example.com/orclpdb") ``` ```text Connecting to the database as hr ``` -------------------------------- ### Invoking PEM Creation Script Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html Example of how to run the create_pem.py script from the command line, providing the wallet password and the directory containing the PKCS12 file. ```bash python create_pem.py --wallet-password 'xxxxx' /Users/scott/cloud_configs/MYDBDIR ``` -------------------------------- ### Install python-oracledb using pip Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs or upgrades the python-oracledb package from PyPI using Python's pip package manager. ```bash python -m pip install oracledb --upgrade ``` -------------------------------- ### Connection Pool with External Authentication Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/authentication_methods.html This example demonstrates creating a connection pool with external authentication. It configures the pool with specific settings for minimum and maximum connections, and homogeneous pool behavior. ```python pool = oracledb.create_pool(dsn=db_alias, externalauth=True, homogeneous=False, min=1, max=2, increment=1) connection = pool.acquire() ``` -------------------------------- ### Configure Oracle Instant Client with custom configuration directory Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Initializes the python-oracledb client with a specified directory for Oracle configuration files like `tnsnames.ora`. ```python import oracledb oracledb.init_oracle_client(config_dir="/opt/oracle/your_config_dir") ``` -------------------------------- ### Create Table for Direct Path Load Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/batch_statement.html Defines a sample table structure for demonstrating Direct Path Loads. ```sql create table TestDirectPathLoad ( id number(9), name varchar2(20) ); ``` -------------------------------- ### Install Specific python-oracledb Version Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Use pip to install a particular version of the python-oracledb package by specifying the version number with the '==' operator. ```bash python -m pip install oracledb==3.2.0 ``` -------------------------------- ### Create a Custom Protocol Plugin Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/extending.html This example demonstrates how to create a custom plugin that intercepts and processes connection strings with a specific protocol prefix. It requires creating a package structure and registering a hook function. ```bash mkdir myplugin ``` ```text My sample connection plugin. ``` ```toml [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" ``` ```ini [metadata] name = myplugin version = 1.0.0 description = Sample connection plugin for python-oracleb long_description = file: README long_description_content_type = text/markdown author = Your Name author_email = youremail@example.com license = Apache Software License [options] zip_safe = False package_dir = =src install_requires = oracledb [options.packages.find] where = src ``` ```bash mkdir -p src/oracledb/plugins ``` ```python import oracledb def myhookfunc(protocol, arg, params): print(f"In myhookfunc: protocol={protocol} arg={arg}") params.parse_connect_string(arg) oracledb.register_protocol("myprefix", myhookfunc) ``` ```bash python -m pip install build python -m build ``` ```bash python -m pip install dist/myplugin-1.0.0-py3-none-any.whl ``` ```python import oracledb import oracledb.plugins.myplugin cs = "myprefix://localhost/orclpdb" cp = oracledb.ConnectParams() cp.parse_connect_string(cs) print(f"host={cp.host}, port={cp.port}, service name={cp.service_name}") ``` ```text In myhookfunc: protocol=myprefix arg=localhost/orclpdb host=localhost, port=1521, service name=orclpdb ``` ```bash python -m pip uninstall myplugin ``` -------------------------------- ### Example Fetched BINARY Vector Data Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/vector_data_type.html This is an example of the output when fetching BINARY vector data, which is represented as a Python array.array('B') object. ```python (array("B", [180, 150, 100])) ``` -------------------------------- ### Thin Mode Service Not Registered Error Example Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/exception_handling.html An example of a python-oracledb Thin mode error message when the requested database service is not registered with the listener. ```text DPY-6001: cannot connect to database. Service "{service_name}" is not registered with the listener at host "{host}" port {port}. (Similar to ORA-12514) ``` -------------------------------- ### Thin Mode Binding Error Example Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/exception_handling.html Presents an example of an error message generated by python-oracledb Thin mode when a bind variable is missing during execution. ```text DPY-4010: a bind variable replacement value for placeholder ":1" was not provided ``` -------------------------------- ### Install libnsl Package on Linux Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the libnsl package, which may be required on certain Linux distributions like Oracle Linux 8 for libnsl.so availability. ```bash sudo dnf install libnsl ``` -------------------------------- ### Create Collection and Insert Document Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/soda.html Demonstrates how to get a SODA database handle, create a new collection (or open an existing one), and insert a JSON document represented as a Python dictionary. The key of the newly inserted document is then printed. ```python soda = connection.getSodaDatabase() # create a new SODA collection; this will open an existing collection, if # the name is already in use collection = soda.createCollection("mycollection") # insert a document into the collection; for the common case of a JSON # document, the content can be a simple Python dictionary which will # internally be converted to a JSON document content = {'name': 'Matilda', 'address': {'city': 'Melbourne'}} returned_doc = collection.insertOneAndGet(content) key = returned_doc.key print('The key of the new SODA document is: ', key) ``` -------------------------------- ### Example Fetched Vector Data Format Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/vector_data_type.html Illustrates the expected output format when fetching vector data that has been configured to be returned as NumPy arrays. ```text (array([1.625, 1.5, 1.0], dtype=float32), array([11.25, 11.75, 11.5], dtype=float64), array([1, 2, 3], dtype=int8), array([180, 150, 100], dtype=uint8)) ``` -------------------------------- ### Install AWS Centralized Configuration Providers Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the python-oracledb package with the optional [aws_config] dependency, including the Boto3 package for AWS S3 and Secrets Manager integration. ```bash python -m pip install oracledb[aws_config] ``` -------------------------------- ### Initialize Thick Mode without lib_dir on Windows Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/initialization.html On Windows, call init_oracle_client() without parameters to let the driver search for libraries in its own installation directory or the system's PATH. ```python import oracledb oracledb.init_oracle_client() ``` -------------------------------- ### Install Azure App Configuration Provider Source: https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html Installs the python-oracledb package with the optional [azure_config] dependency, including necessary Azure packages for the Azure App Configuration provider. ```bash python -m pip install oracledb[azure_config] ```