diff --git a/python/python-oracledb/README.md b/python/python-oracledb/README.md index f1a4e706..380ce058 100644 --- a/python/python-oracledb/README.md +++ b/python/python-oracledb/README.md @@ -34,8 +34,8 @@ build a container with the samples and a running Oracle Database. ### Notebooks -The [sample_notebooks](./sample_notebooks) directory has Jupyter notebooks with -runnable examples. +The [notebooks](./notebooks) directory has Jupyter notebooks with runnable +examples. ## About python-oracledb diff --git a/python/python-oracledb/app_context.py b/python/python-oracledb/app_context.py index 8757764d..2f733bae 100644 --- a/python/python-oracledb/app_context.py +++ b/python/python-oracledb/app_context.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -38,8 +38,9 @@ import oracledb import sample_env -# this script is currently only supported in python-oracledb thick mode -oracledb.init_oracle_client(lib_dir=sample_env.get_oracle_client()) +# determine whether to use python-oracledb thin mode or thick mode +if not sample_env.get_is_thin(): + oracledb.init_oracle_client(lib_dir=sample_env.get_oracle_client()) # client context attributes to be set APP_CTX_NAMESPACE = "CLIENTCONTEXT" diff --git a/python/python-oracledb/array_dml_rowcounts.py b/python/python-oracledb/array_dml_rowcounts.py index 47fc3b1c..7a497f01 100644 --- a/python/python-oracledb/array_dml_rowcounts.py +++ b/python/python-oracledb/array_dml_rowcounts.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -42,6 +42,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/array_dml_rowcounts_async.py b/python/python-oracledb/array_dml_rowcounts_async.py index 8b5b72b1..a8661af1 100644 --- a/python/python-oracledb/array_dml_rowcounts_async.py +++ b/python/python-oracledb/array_dml_rowcounts_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -44,6 +44,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/async_gather.py b/python/python-oracledb/async_gather.py index cc21fc1d..78b12937 100644 --- a/python/python-oracledb/async_gather.py +++ b/python/python-oracledb/async_gather.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -66,6 +66,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_pool_params(), min=1, max=CONCURRENCY, session_callback=init_session, diff --git a/python/python-oracledb/batch_errors.py b/python/python-oracledb/batch_errors.py index b5ef1b26..60e5a4bd 100644 --- a/python/python-oracledb/batch_errors.py +++ b/python/python-oracledb/batch_errors.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -44,6 +44,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/batch_errors_async.py b/python/python-oracledb/batch_errors_async.py index 3c865bbc..3297fb6a 100644 --- a/python/python-oracledb/batch_errors_async.py +++ b/python/python-oracledb/batch_errors_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -46,6 +46,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/bind_insert.py b/python/python-oracledb/bind_insert.py index 5bb6b3c6..abd7750f 100644 --- a/python/python-oracledb/bind_insert.py +++ b/python/python-oracledb/bind_insert.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -39,6 +39,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # ----------------------------------------------------------------------------- diff --git a/python/python-oracledb/bind_insert_async.py b/python/python-oracledb/bind_insert_async.py index 853281cf..2e3a3660 100644 --- a/python/python-oracledb/bind_insert_async.py +++ b/python/python-oracledb/bind_insert_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -41,6 +41,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # ------------------------------------------------------------------------- diff --git a/python/python-oracledb/bind_query.py b/python/python-oracledb/bind_query.py index e286cf4c..9a114cab 100644 --- a/python/python-oracledb/bind_query.py +++ b/python/python-oracledb/bind_query.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -44,6 +44,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # Bind by position with lists diff --git a/python/python-oracledb/bind_query_async.py b/python/python-oracledb/bind_query_async.py index 836bcdd5..69a938ad 100644 --- a/python/python-oracledb/bind_query_async.py +++ b/python/python-oracledb/bind_query_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -46,6 +46,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # Bind by position with lists diff --git a/python/python-oracledb/call_timeout.py b/python/python-oracledb/call_timeout.py index 965ed7fd..5fc59b1e 100644 --- a/python/python-oracledb/call_timeout.py +++ b/python/python-oracledb/call_timeout.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2019, 2023, Oracle and/or its affiliates. +# Copyright (c) 2019, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -43,6 +43,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) connection.call_timeout = 2000 diff --git a/python/python-oracledb/call_timeout_async.py b/python/python-oracledb/call_timeout_async.py index 446a710d..c136c01f 100644 --- a/python/python-oracledb/call_timeout_async.py +++ b/python/python-oracledb/call_timeout_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -43,6 +43,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) connection.call_timeout = 2000 diff --git a/python/python-oracledb/connection_pool.py b/python/python-oracledb/connection_pool.py index 92e6a2ad..dd76c05e 100644 --- a/python/python-oracledb/connection_pool.py +++ b/python/python-oracledb/connection_pool.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2022, 2023, Oracle and/or its affiliates. +# Copyright (c) 2022, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -89,6 +89,7 @@ def start_pool(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_pool_params(), min=pool_min, max=pool_max, increment=pool_inc, diff --git a/python/python-oracledb/create_schema.py b/python/python-oracledb/create_schema.py index d5ad7d93..d2bc0997 100644 --- a/python/python-oracledb/create_schema.py +++ b/python/python-oracledb/create_schema.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. +# Copyright (c) 2020, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -54,7 +54,7 @@ sample_env.run_sql_script( conn, "create_schema_21", main_user=sample_env.get_main_user() ) -if sample_env.get_server_version() >= (23, 4): +if sample_env.get_server_version() >= (23, 5): sample_env.run_sql_script( conn, "create_schema_23", main_user=sample_env.get_main_user() ) diff --git a/python/python-oracledb/dbms_output.py b/python/python-oracledb/dbms_output.py index 0f2202ff..0366af84 100644 --- a/python/python-oracledb/dbms_output.py +++ b/python/python-oracledb/dbms_output.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. +# Copyright (c) 2020, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -40,6 +40,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/dbms_output_async.py b/python/python-oracledb/dbms_output_async.py index a0f5b2d6..757db241 100644 --- a/python/python-oracledb/dbms_output_async.py +++ b/python/python-oracledb/dbms_output_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -42,6 +42,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/dml_returning_multiple_rows.py b/python/python-oracledb/dml_returning_multiple_rows.py index f6464ba8..7f7765f4 100644 --- a/python/python-oracledb/dml_returning_multiple_rows.py +++ b/python/python-oracledb/dml_returning_multiple_rows.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2017, 2023, Oracle and/or its affiliates. +# Copyright (c) 2017, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -45,6 +45,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/dml_returning_multiple_rows_async.py b/python/python-oracledb/dml_returning_multiple_rows_async.py index 1a2963e0..2bda224b 100644 --- a/python/python-oracledb/dml_returning_multiple_rows_async.py +++ b/python/python-oracledb/dml_returning_multiple_rows_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -42,6 +42,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/drcp_pool.py b/python/python-oracledb/drcp_pool.py index 3ff8aef8..2401021e 100644 --- a/python/python-oracledb/drcp_pool.py +++ b/python/python-oracledb/drcp_pool.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2022, 2023, Oracle and/or its affiliates. +# Copyright (c) 2022, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -137,6 +137,7 @@ def start_pool(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_drcp_connect_string(), + params=sample_env.get_pool_params(), min=pool_min, max=pool_max, increment=pool_inc, diff --git a/python/python-oracledb/editioning.py b/python/python-oracledb/editioning.py index 3ba403f8..c6d579d2 100644 --- a/python/python-oracledb/editioning.py +++ b/python/python-oracledb/editioning.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -41,8 +41,9 @@ import oracledb import sample_env -# this script is currently only supported in python-oracledb thick mode -oracledb.init_oracle_client(lib_dir=sample_env.get_oracle_client()) +# determine whether to use python-oracledb thin mode or thick mode +if not sample_env.get_is_thin(): + oracledb.init_oracle_client(lib_dir=sample_env.get_oracle_client()) # connect to the editions user and create a procedure edition_connect_string = sample_env.get_edition_connect_string() diff --git a/python/python-oracledb/generic_row_factory.py b/python/python-oracledb/generic_row_factory.py index e1a4bbfd..b7821828 100644 --- a/python/python-oracledb/generic_row_factory.py +++ b/python/python-oracledb/generic_row_factory.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -61,6 +61,7 @@ def execute(self, statement, args=None): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/generic_row_factory_async.py b/python/python-oracledb/generic_row_factory_async.py index 4b4ed55a..e1efdbf4 100644 --- a/python/python-oracledb/generic_row_factory_async.py +++ b/python/python-oracledb/generic_row_factory_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -62,6 +62,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/implicit_results.py b/python/python-oracledb/implicit_results.py index c4ffe332..99e7ca6b 100644 --- a/python/python-oracledb/implicit_results.py +++ b/python/python-oracledb/implicit_results.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -46,6 +46,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/implicit_results_async.py b/python/python-oracledb/implicit_results_async.py index c2afc323..95841274 100644 --- a/python/python-oracledb/implicit_results_async.py +++ b/python/python-oracledb/implicit_results_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -43,6 +43,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/insert_geometry.py b/python/python-oracledb/insert_geometry.py index 60938fa2..bf6f5699 100644 --- a/python/python-oracledb/insert_geometry.py +++ b/python/python-oracledb/insert_geometry.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -45,6 +45,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # create and populate Oracle objects diff --git a/python/python-oracledb/insert_geometry_async.py b/python/python-oracledb/insert_geometry_async.py index a9058fde..22fe92d4 100644 --- a/python/python-oracledb/insert_geometry_async.py +++ b/python/python-oracledb/insert_geometry_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -42,6 +42,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # create and populate Oracle objects diff --git a/python/python-oracledb/json_blob.py b/python/python-oracledb/json_blob.py index 90757fa7..61b8576f 100644 --- a/python/python-oracledb/json_blob.py +++ b/python/python-oracledb/json_blob.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. +# Copyright (c) 2020, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -50,6 +50,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) if not connection.thin: diff --git a/python/python-oracledb/json_blob_async.py b/python/python-oracledb/json_blob_async.py index 7f7e18b8..d8b9221d 100644 --- a/python/python-oracledb/json_blob_async.py +++ b/python/python-oracledb/json_blob_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -51,6 +51,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # Minimum database vesion is 12 diff --git a/python/python-oracledb/json_direct.py b/python/python-oracledb/json_direct.py index fcccdf83..3b2219fb 100644 --- a/python/python-oracledb/json_direct.py +++ b/python/python-oracledb/json_direct.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. +# Copyright (c) 2020, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -47,6 +47,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) if not connection.thin: diff --git a/python/python-oracledb/json_direct_async.py b/python/python-oracledb/json_direct_async.py index a2c19628..7272c842 100644 --- a/python/python-oracledb/json_direct_async.py +++ b/python/python-oracledb/json_direct_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -47,6 +47,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # this script only works with Oracle Database 21 diff --git a/python/python-oracledb/json_duality.py b/python/python-oracledb/json_duality.py index 393049e7..cc0829da 100644 --- a/python/python-oracledb/json_duality.py +++ b/python/python-oracledb/json_duality.py @@ -46,6 +46,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # this script only works with Oracle Database 23.5 or later diff --git a/python/python-oracledb/json_duality_async.py b/python/python-oracledb/json_duality_async.py index 6546d3c2..9fd8bf38 100644 --- a/python/python-oracledb/json_duality_async.py +++ b/python/python-oracledb/json_duality_async.py @@ -44,6 +44,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # this script only works with Oracle Database 23.5 or later diff --git a/python/python-oracledb/last_rowid.py b/python/python-oracledb/last_rowid.py index 323bc2c0..bbe3583b 100644 --- a/python/python-oracledb/last_rowid.py +++ b/python/python-oracledb/last_rowid.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2019, 2023, Oracle and/or its affiliates. +# Copyright (c) 2019, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -39,6 +39,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/last_rowid_async.py b/python/python-oracledb/last_rowid_async.py index 3f4a2a68..20c8e472 100644 --- a/python/python-oracledb/last_rowid_async.py +++ b/python/python-oracledb/last_rowid_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -41,6 +41,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/load_csv.py b/python/python-oracledb/load_csv.py index 045c1c88..49d28e10 100644 --- a/python/python-oracledb/load_csv.py +++ b/python/python-oracledb/load_csv.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2022, 2023, Oracle and/or its affiliates. +# Copyright (c) 2022, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -53,6 +53,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) diff --git a/python/python-oracledb/load_csv_async.py b/python/python-oracledb/load_csv_async.py index e862e733..3a5be68b 100644 --- a/python/python-oracledb/load_csv_async.py +++ b/python/python-oracledb/load_csv_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -54,6 +54,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) async def process_batch(batch_number, cursor, data): diff --git a/python/python-oracledb/sample_notebooks/1-Connection.ipynb b/python/python-oracledb/notebooks/1-Connection.ipynb similarity index 100% rename from python/python-oracledb/sample_notebooks/1-Connection.ipynb rename to python/python-oracledb/notebooks/1-Connection.ipynb diff --git a/python/python-oracledb/sample_notebooks/2-Queries.ipynb b/python/python-oracledb/notebooks/2-Queries.ipynb similarity index 100% rename from python/python-oracledb/sample_notebooks/2-Queries.ipynb rename to python/python-oracledb/notebooks/2-Queries.ipynb diff --git a/python/python-oracledb/sample_notebooks/3-DML.ipynb b/python/python-oracledb/notebooks/3-DML.ipynb similarity index 100% rename from python/python-oracledb/sample_notebooks/3-DML.ipynb rename to python/python-oracledb/notebooks/3-DML.ipynb diff --git a/python/python-oracledb/sample_notebooks/4-CSV.ipynb b/python/python-oracledb/notebooks/4-CSV.ipynb similarity index 100% rename from python/python-oracledb/sample_notebooks/4-CSV.ipynb rename to python/python-oracledb/notebooks/4-CSV.ipynb diff --git a/python/python-oracledb/sample_notebooks/5-JSON.ipynb b/python/python-oracledb/notebooks/5-JSON.ipynb similarity index 100% rename from python/python-oracledb/sample_notebooks/5-JSON.ipynb rename to python/python-oracledb/notebooks/5-JSON.ipynb diff --git a/python/python-oracledb/sample_notebooks/6-PLSQL.ipynb b/python/python-oracledb/notebooks/6-PLSQL.ipynb similarity index 100% rename from python/python-oracledb/sample_notebooks/6-PLSQL.ipynb rename to python/python-oracledb/notebooks/6-PLSQL.ipynb diff --git a/python/python-oracledb/sample_notebooks/7-Objects.ipynb b/python/python-oracledb/notebooks/7-Objects.ipynb similarity index 100% rename from python/python-oracledb/sample_notebooks/7-Objects.ipynb rename to python/python-oracledb/notebooks/7-Objects.ipynb diff --git a/python/python-oracledb/sample_notebooks/README.md b/python/python-oracledb/notebooks/README.md similarity index 98% rename from python/python-oracledb/sample_notebooks/README.md rename to python/python-oracledb/notebooks/README.md index dee07944..37d2a382 100644 --- a/python/python-oracledb/sample_notebooks/README.md +++ b/python/python-oracledb/notebooks/README.md @@ -67,7 +67,7 @@ Install the schema: ### Start Jupyter - cd sample_notebooks + cd notebooks jupyter notebook If Jupyter is not in your path, you may need to find it on your computer and diff --git a/python/python-oracledb/sample_notebooks/csv/data1.csv b/python/python-oracledb/notebooks/csv/data1.csv similarity index 100% rename from python/python-oracledb/sample_notebooks/csv/data1.csv rename to python/python-oracledb/notebooks/csv/data1.csv diff --git a/python/python-oracledb/sample_notebooks/images/architecture-thin.png b/python/python-oracledb/notebooks/images/architecture-thin.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/architecture-thin.png rename to python/python-oracledb/notebooks/images/architecture-thin.png diff --git a/python/python-oracledb/sample_notebooks/images/banner.png b/python/python-oracledb/notebooks/images/banner.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/banner.png rename to python/python-oracledb/notebooks/images/banner.png diff --git a/python/python-oracledb/sample_notebooks/images/drcp-architecture.png b/python/python-oracledb/notebooks/images/drcp-architecture.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/drcp-architecture.png rename to python/python-oracledb/notebooks/images/drcp-architecture.png diff --git a/python/python-oracledb/sample_notebooks/images/drcp-comparison.png b/python/python-oracledb/notebooks/images/drcp-comparison.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/drcp-comparison.png rename to python/python-oracledb/notebooks/images/drcp-comparison.png diff --git a/python/python-oracledb/sample_notebooks/images/jupyter-notebook-screenshot.png b/python/python-oracledb/notebooks/images/jupyter-notebook-screenshot.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/jupyter-notebook-screenshot.png rename to python/python-oracledb/notebooks/images/jupyter-notebook-screenshot.png diff --git a/python/python-oracledb/sample_notebooks/images/lob-benchmark.png b/python/python-oracledb/notebooks/images/lob-benchmark.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/lob-benchmark.png rename to python/python-oracledb/notebooks/images/lob-benchmark.png diff --git a/python/python-oracledb/sample_notebooks/images/pooled-connection.png b/python/python-oracledb/notebooks/images/pooled-connection.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/pooled-connection.png rename to python/python-oracledb/notebooks/images/pooled-connection.png diff --git a/python/python-oracledb/sample_notebooks/images/roundtrip.png b/python/python-oracledb/notebooks/images/roundtrip.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/roundtrip.png rename to python/python-oracledb/notebooks/images/roundtrip.png diff --git a/python/python-oracledb/sample_notebooks/images/standalone-connection.png b/python/python-oracledb/notebooks/images/standalone-connection.png similarity index 100% rename from python/python-oracledb/sample_notebooks/images/standalone-connection.png rename to python/python-oracledb/notebooks/images/standalone-connection.png diff --git a/python/python-oracledb/object_dump.py b/python/python-oracledb/object_dump.py index 741d9a10..b6ce6412 100644 --- a/python/python-oracledb/object_dump.py +++ b/python/python-oracledb/object_dump.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -41,6 +41,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) cursor = connection.cursor() diff --git a/python/python-oracledb/object_dump_async.py b/python/python-oracledb/object_dump_async.py index 50e9a028..9061c3ef 100644 --- a/python/python-oracledb/object_dump_async.py +++ b/python/python-oracledb/object_dump_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -43,6 +43,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) cursor = connection.cursor() diff --git a/python/python-oracledb/pipelining_basic.py b/python/python-oracledb/pipelining_basic.py new file mode 100644 index 00000000..76bb1786 --- /dev/null +++ b/python/python-oracledb/pipelining_basic.py @@ -0,0 +1,92 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2024, Oracle and/or its affiliates. +# +# This software is dual-licensed to you under the Universal Permissive License +# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License +# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose +# either license. +# +# If you elect to accept the software under the Apache License, Version 2.0, +# the following applies: +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# pipelining_basic.py +# +# Demonstrates Oracle Database Pipelining. +# True pipelining is only available when connected to Oracle Database 23ai +# ----------------------------------------------------------------------------- + +import asyncio + +import oracledb +import sample_env + + +async def main(): + connection = await oracledb.connect_async( + user=sample_env.get_main_user(), + password=sample_env.get_main_password(), + dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), + ) + + # ------------------------------------------------------------ + + # Create a pipeline and define the operations + pipeline = oracledb.create_pipeline() + + pipeline.add_fetchone("select user from dual") + + pipeline.add_fetchone("select sysdate from dual") + + rows = [ + (1, "First"), + (2, "Second"), + (3, "Third"), + (4, "Fourth"), + (5, "Fifth"), + (6, "Sixth"), + ] + pipeline.add_executemany( + "insert into mytab(id, data) values (:1, :2)", rows + ) + + # pipeline.add_commit() # uncomment to persist data + + pipeline.add_fetchall("select * from mytab") + + # Run the operations in the pipeline. + # Note although the database receives all the operations at the same time, + # it will execute each operation sequentially + results = await connection.run_pipeline(pipeline) + + # Print the query results + for i, result in enumerate(results): + if result.rows: + statement = pipeline.operations[i].statement + print(f"\nRows from operation {i+1} '{statement}':\n") + headings = [col.name for col in result.columns] + print(*headings, sep="\t") + print("--") + for row in result.rows: + print(*row, sep="\t") + + # ------------------------------------------------------------ + + await connection.close() + + +asyncio.run(main()) diff --git a/python/python-oracledb/pipelining_error.py b/python/python-oracledb/pipelining_error.py new file mode 100644 index 00000000..92190083 --- /dev/null +++ b/python/python-oracledb/pipelining_error.py @@ -0,0 +1,106 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2024, Oracle and/or its affiliates. +# +# This software is dual-licensed to you under the Universal Permissive License +# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License +# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose +# either license. +# +# If you elect to accept the software under the Apache License, Version 2.0, +# the following applies: +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# pipelining_error.py +# +# Demonstrates warnings and errors with Oracle Database Pipelining. +# True pipelining is only available when connected to Oracle Database 23ai +# ----------------------------------------------------------------------------- + +import asyncio + +import oracledb +import sample_env + + +async def main(): + connection = await oracledb.connect_async( + user=sample_env.get_main_user(), + password=sample_env.get_main_password(), + dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), + ) + + # ------------------------------------------------------------ + + print("\nExecution exception:\n") + + try: + pipeline = oracledb.create_pipeline() + pipeline.add_fetchall("select 1 from does_not_exist_1") + pipeline.add_fetchall("select 2 from does_not_exist_2") + + # By default, the first failure throws an exception + await connection.run_pipeline(pipeline) + + except oracledb.Error as e: + (error,) = e.args + print(error.message) + + # ------------------------------------------------------------ + + print("\nContinuing after first error:\n") + + pipeline = oracledb.create_pipeline() + pipeline.add_execute( + """create or replace procedure myproc as + begin + bogus; + end;""" + ) + pipeline.add_fetchall("select 1 from does_not_exist_3") + pipeline.add_fetchall("select 2 from does_not_exist_4") + pipeline.add_fetchall("select dummy from dual") + results = await connection.run_pipeline(pipeline, continue_on_error=True) + + for i, result in enumerate(results): + statement = pipeline.operations[i].statement + if result.warning: + print( + f"Warning {result.warning.full_code} " f"in operation {i+1}:\n" + ) + print(statement) + print(f"{result.warning}\n") + elif result.error: + print( + f"Error {result.error.full_code} " + f"at position {result.error.offset+1} " + f"in operation {i+1}:\n" + ) + print(statement) + print(f"{result.error}\n") + elif result.rows: + print(f"Rows from operation {i+1}:\n") + print(statement) + for row in result.rows: + print(row) + + # ------------------------------------------------------------ + + await connection.execute("drop procedure myproc") + await connection.close() + + +asyncio.run(main()) diff --git a/python/python-oracledb/pipelining_parallel.py b/python/python-oracledb/pipelining_parallel.py new file mode 100644 index 00000000..4b318a71 --- /dev/null +++ b/python/python-oracledb/pipelining_parallel.py @@ -0,0 +1,79 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2024, Oracle and/or its affiliates. +# +# This software is dual-licensed to you under the Universal Permissive License +# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License +# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose +# either license. +# +# If you elect to accept the software under the Apache License, Version 2.0, +# the following applies: +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# pipelining_parallel.py +# +# Demonstrates Oracle Database Pipelining running local and database operations +# concurrently. +# True pipelining is only available when connected to Oracle Database 23ai +# ----------------------------------------------------------------------------- + +import asyncio + +import oracledb +import sample_env + + +async def run_thing_one(): + return "thing_one" + + +async def run_thing_two(): + return "thing_two" + + +async def main(): + connection = await oracledb.connect_async( + user=sample_env.get_main_user(), + password=sample_env.get_main_password(), + dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), + ) + + pipeline = oracledb.create_pipeline() + pipeline.add_fetchone("select user from dual") + pipeline.add_fetchone("select sysdate from dual") + + # Run the pipeline and non-database operations concurrently. + # Note although the database receives all the operations at the same time, + # it will execute each operation sequentially. It is the local and + # database tasks that execute concurrently. + return_values = await asyncio.gather( + run_thing_one(), run_thing_two(), connection.run_pipeline(pipeline) + ) + + for r in return_values: + if isinstance(r, list): # the pipeline return list + for result in r: + if result.rows: + for row in result.rows: + print(*row, sep="\t") + else: + print(r) # a local operation result + + await connection.close() + + +asyncio.run(main()) diff --git a/python/python-oracledb/plsql_collection.py b/python/python-oracledb/plsql_collection.py index 33687031..009f581c 100644 --- a/python/python-oracledb/plsql_collection.py +++ b/python/python-oracledb/plsql_collection.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -42,6 +42,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # create a new empty object of the correct type. diff --git a/python/python-oracledb/plsql_collection_async.py b/python/python-oracledb/plsql_collection_async.py index e39d11f7..a6d07e98 100644 --- a/python/python-oracledb/plsql_collection_async.py +++ b/python/python-oracledb/plsql_collection_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -44,6 +44,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # create a new empty object of the correct type. diff --git a/python/python-oracledb/plsql_function.py b/python/python-oracledb/plsql_function.py index 36679742..5d75a743 100644 --- a/python/python-oracledb/plsql_function.py +++ b/python/python-oracledb/plsql_function.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -39,6 +39,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/plsql_function_async.py b/python/python-oracledb/plsql_function_async.py index 4606c3ba..df10d73e 100644 --- a/python/python-oracledb/plsql_function_async.py +++ b/python/python-oracledb/plsql_function_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -41,6 +41,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/plsql_procedure.py b/python/python-oracledb/plsql_procedure.py index 7703cff3..3a30879f 100644 --- a/python/python-oracledb/plsql_procedure.py +++ b/python/python-oracledb/plsql_procedure.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -40,6 +40,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/plsql_procedure_async.py b/python/python-oracledb/plsql_procedure_async.py index d5c9875e..eefe48cb 100644 --- a/python/python-oracledb/plsql_procedure_async.py +++ b/python/python-oracledb/plsql_procedure_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -42,6 +42,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/plsql_record.py b/python/python-oracledb/plsql_record.py index d3bc2a9c..e6962230 100644 --- a/python/python-oracledb/plsql_record.py +++ b/python/python-oracledb/plsql_record.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -43,6 +43,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # create new object of the correct type diff --git a/python/python-oracledb/plsql_record_async.py b/python/python-oracledb/plsql_record_async.py index 633b1f40..61c5165a 100644 --- a/python/python-oracledb/plsql_record_async.py +++ b/python/python-oracledb/plsql_record_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -44,6 +44,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # create new object of the correct type diff --git a/python/python-oracledb/plsql_rowtype.py b/python/python-oracledb/plsql_rowtype.py index aebbefb8..d7d38538 100644 --- a/python/python-oracledb/plsql_rowtype.py +++ b/python/python-oracledb/plsql_rowtype.py @@ -39,6 +39,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/plsql_rowtype_async.py b/python/python-oracledb/plsql_rowtype_async.py index 8a02e41a..68371897 100644 --- a/python/python-oracledb/plsql_rowtype_async.py +++ b/python/python-oracledb/plsql_rowtype_async.py @@ -41,6 +41,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/query.py b/python/python-oracledb/query.py index 8a0d42e6..283e0b1b 100644 --- a/python/python-oracledb/query.py +++ b/python/python-oracledb/query.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -39,6 +39,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) sql = """select * from SampleQueryTab diff --git a/python/python-oracledb/query_arraysize.py b/python/python-oracledb/query_arraysize.py index 3d1af672..9ef713bb 100644 --- a/python/python-oracledb/query_arraysize.py +++ b/python/python-oracledb/query_arraysize.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -48,6 +48,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # Global values can be set to override the defaults used when a cursor is diff --git a/python/python-oracledb/query_arraysize_async.py b/python/python-oracledb/query_arraysize_async.py index 965bcc8c..ec6330fc 100644 --- a/python/python-oracledb/query_arraysize_async.py +++ b/python/python-oracledb/query_arraysize_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -49,6 +49,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # Global values can be set to override the defaults used when a cursor is diff --git a/python/python-oracledb/query_async.py b/python/python-oracledb/query_async.py index d12b4a59..bd5f97a9 100644 --- a/python/python-oracledb/query_async.py +++ b/python/python-oracledb/query_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -41,6 +41,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) sql = """select * from SampleQueryTab diff --git a/python/python-oracledb/query_strings_as_bytes.py b/python/python-oracledb/query_strings_as_bytes.py index 102c097b..fa2115bd 100644 --- a/python/python-oracledb/query_strings_as_bytes.py +++ b/python/python-oracledb/query_strings_as_bytes.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2021, 2023, Oracle and/or its affiliates. +# Copyright (c) 2021, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -49,6 +49,7 @@ def return_strings_as_bytes(cursor, metadata): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # truncate table and populate with our data of choice diff --git a/python/python-oracledb/query_strings_as_bytes_async.py b/python/python-oracledb/query_strings_as_bytes_async.py index 984ec02c..df64db39 100644 --- a/python/python-oracledb/query_strings_as_bytes_async.py +++ b/python/python-oracledb/query_strings_as_bytes_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -50,6 +50,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) # truncate table and populate with our data of choice diff --git a/python/python-oracledb/ref_cursor.py b/python/python-oracledb/ref_cursor.py index d6a99ed1..537fae6b 100644 --- a/python/python-oracledb/ref_cursor.py +++ b/python/python-oracledb/ref_cursor.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2018, 2023, Oracle and/or its affiliates. +# Copyright (c) 2018, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -41,6 +41,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/ref_cursor_async.py b/python/python-oracledb/ref_cursor_async.py index 8de5b727..4abbca40 100644 --- a/python/python-oracledb/ref_cursor_async.py +++ b/python/python-oracledb/ref_cursor_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -42,6 +42,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) ref_cursor = connection.cursor() diff --git a/python/python-oracledb/return_lobs_as_strings.py b/python/python-oracledb/return_lobs_as_strings.py index 71a33e39..4e07a57e 100644 --- a/python/python-oracledb/return_lobs_as_strings.py +++ b/python/python-oracledb/return_lobs_as_strings.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -51,6 +51,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/return_lobs_as_strings_async.py b/python/python-oracledb/return_lobs_as_strings_async.py index 8259cfb6..686d5a46 100644 --- a/python/python-oracledb/return_lobs_as_strings_async.py +++ b/python/python-oracledb/return_lobs_as_strings_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -48,6 +48,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/return_numbers_as_decimals.py b/python/python-oracledb/return_numbers_as_decimals.py index eaeed69c..aef2bf26 100644 --- a/python/python-oracledb/return_numbers_as_decimals.py +++ b/python/python-oracledb/return_numbers_as_decimals.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2017, 2023, Oracle and/or its affiliates. +# Copyright (c) 2017, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -46,6 +46,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/return_numbers_as_decimals_async.py b/python/python-oracledb/return_numbers_as_decimals_async.py index f304e98c..d3a063a6 100644 --- a/python/python-oracledb/return_numbers_as_decimals_async.py +++ b/python/python-oracledb/return_numbers_as_decimals_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -48,6 +48,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/rows_as_instance.py b/python/python-oracledb/rows_as_instance.py index 67973a93..c17150c7 100644 --- a/python/python-oracledb/rows_as_instance.py +++ b/python/python-oracledb/rows_as_instance.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -54,6 +54,7 @@ def __init__(self, a, b, c): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/rows_as_instance_async.py b/python/python-oracledb/rows_as_instance_async.py index 41a0402b..9ceaba4d 100644 --- a/python/python-oracledb/rows_as_instance_async.py +++ b/python/python-oracledb/rows_as_instance_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -50,6 +50,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/sample_container/Dockerfile b/python/python-oracledb/sample_container/Dockerfile index 85caa1a3..abae563c 100644 --- a/python/python-oracledb/sample_container/Dockerfile +++ b/python/python-oracledb/sample_container/Dockerfile @@ -86,7 +86,7 @@ WORKDIR /samples/ RUN curl -LO https://github.com/oracle/python-oracledb/archive/refs/heads/main.zip && \ unzip main.zip && \ cp python-oracledb-main/samples/sample_container/setup.py . && \ - /bin/rm -rf python-oracledb-main/samples/sample_container/ python-oracledb-main/samples/sample_notebooks/ && \ + /bin/rm -rf python-oracledb-main/samples/sample_container/ python-oracledb-main/samples/notebooks/ && \ mv python-oracledb-main/samples/* . && \ /bin/rm -rf python-oracledb-main samples main.zip && \ cat create_schema.py >> /samples/setup.py && \ diff --git a/python/python-oracledb/sample_env.py b/python/python-oracledb/sample_env.py index b975796c..062f0dd7 100644 --- a/python/python-oracledb/sample_env.py +++ b/python/python-oracledb/sample_env.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2017, 2023, Oracle and/or its affiliates. +# Copyright (c) 2017, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -40,6 +40,8 @@ # PYO_SAMPLES_EDITION_USER: user to be created for editiong samples # PYO_SAMPLES_EDITION_PASSWORD: password of PYO_SAMPLES_EDITION_USER # PYO_SAMPLES_EDITION_NAME: name of edition for editioning samples +# PYO_SAMPLES_WALLET_LOCATION: location of wallet file (thin mode, mTLS) +# PYO_SAMPLES_WALLET_PASSWORD: password for wallet file (thin mode, mTLS) # PYO_SAMPLES_DRIVER_MODE: python-oracledb mode (Thick or thin) to use # # - On Windows set PYO_SAMPLES_ORACLE_CLIENT_PATH if Oracle libraries are not @@ -156,6 +158,21 @@ def get_edition_name(): ) +def get_connect_params(cls=oracledb.ConnectParams): + wallet_location = get_wallet_location() + if wallet_location is not None: + return cls( + config_dir=wallet_location, + wallet_location=wallet_location, + wallet_password=get_wallet_password(), + disable_oob=True, + ) + + +def get_pool_params(): + return get_connect_params(cls=oracledb.PoolParams) + + def get_connect_string(): return get_value( "PYO_SAMPLES_CONNECT_STRING", "Connect String", DEFAULT_CONNECT_STRING @@ -229,6 +246,18 @@ def get_server_version(): return value +def get_wallet_location(): + if get_is_thin(): + return get_value("PYO_SAMPLES_WALLET_LOCATION", "Wallet Location") + + +def get_wallet_password(): + if get_is_thin() and get_wallet_location(): + return get_value( + "PYO_SAMPLES_WALLET_PASSWORD", "Wallet Password", password=True + ) + + def run_sql_script(conn, script_name, **kwargs): statement_parts = [] cursor = conn.cursor() diff --git a/python/python-oracledb/session_callback.py b/python/python-oracledb/session_callback.py index 182fe24a..26110592 100644 --- a/python/python-oracledb/session_callback.py +++ b/python/python-oracledb/session_callback.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2019, 2023, Oracle and/or its affiliates. +# Copyright (c) 2019, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -97,6 +97,7 @@ def start_pool(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_pool_params(), min=4, max=4, increment=0, diff --git a/python/python-oracledb/soda_json_duality.py b/python/python-oracledb/soda_json_duality.py index c6ea12d8..ac75882f 100644 --- a/python/python-oracledb/soda_json_duality.py +++ b/python/python-oracledb/soda_json_duality.py @@ -29,7 +29,7 @@ # Simple Oracle Document Access (SODA). # # Oracle Client must be at 23.4 or higher. -# Oracle Database must be at 23.4 or higher. +# Oracle Database must be at 23.5 or higher. # The user must have been granted the SODA_APP privilege. # # Also see json_duality.py diff --git a/python/python-oracledb/spatial_to_geopandas.py b/python/python-oracledb/spatial_to_geopandas.py index d4e634ff..5fe8f496 100644 --- a/python/python-oracledb/spatial_to_geopandas.py +++ b/python/python-oracledb/spatial_to_geopandas.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2018, 2023, Oracle and/or its affiliates. +# Copyright (c) 2018, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -58,6 +58,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) cursor = connection.cursor() diff --git a/python/python-oracledb/sql/create_schema_23.sql b/python/python-oracledb/sql/create_schema_23.sql index 75deb8ee..e96e7f86 100644 --- a/python/python-oracledb/sql/create_schema_23.sql +++ b/python/python-oracledb/sql/create_schema_23.sql @@ -27,14 +27,15 @@ * * Performs the actual work of creating and populating the schemas with the * database objects used by the python-oracledb samples that require Oracle - * Database 23.4 or higher. It is executed by the Python script + * Database 23.5 or higher. It is executed by the Python script * create_schema.py. *---------------------------------------------------------------------------*/ create table &main_user..SampleVectorTab ( - v32 vector(3, float32), - v64 vector(3, float64), - v8 vector(3, int8) + v32 vector(3, float32), + v64 vector(3, float64), + v8 vector(3, int8), + vbin vector(24, binary) ) / @@ -51,26 +52,20 @@ create table &main_user..SampleJRDVBookTab ( ) / -insert into &main_user..SampleJRDVAuthorTab values (1, 'Isabel M. Rich') -/ -insert into &main_user..SampleJRDVAuthorTab values (2, 'Bobbie Cool') -/ -insert into &main_user..SampleJRDVAuthorTab values (3, 'Charlie Shore') +insert into &main_user..SampleJRDVAuthorTab values + (1, 'Isabel M. Rich'), + (2, 'Bobbie Cool'), + (3, 'Charlie Shore') / -insert into &main_user..SampleJRDVBookTab values (1, 'The Mysterious Dog', 1) -/ -insert into &main_user..SampleJRDVBookTab values (2, 'The Mysterious Pony', 1) -/ -insert into &main_user..SampleJRDVBookTab values (3, 'The Mysterious Tiger', 1) -/ -insert into &main_user..SampleJRDVBookTab values (4, 'Self Help for Programmers', 2) -/ -insert into &main_user..SampleJRDVBookTab values (5, 'More Self Help for Programmers', 2) -/ -insert into &main_user..SampleJRDVBookTab values (6, 'Travel Guide Volume I', 3) -/ -insert into &main_user..SampleJRDVBookTab values (7, 'Travel Guide Volume II', 3) +insert into &main_user..SampleJRDVBookTab values + (1, 'The Mysterious Dog', 1), + (2, 'The Mysterious Pony', 1), + (3, 'The Mysterious Tiger', 1), + (4, 'Self Help for Programmers', 2), + (5, 'More Self Help for Programmers', 2), + (6, 'Travel Guide Volume I', 3), + (7, 'Travel Guide Volume II', 3) / commit diff --git a/python/python-oracledb/subclassing.py b/python/python-oracledb/subclassing.py index 4ebccbde..a1ca8aca 100644 --- a/python/python-oracledb/subclassing.py +++ b/python/python-oracledb/subclassing.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -48,6 +48,7 @@ def __init__(self): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) def cursor(self): diff --git a/python/python-oracledb/subclassing_async.py b/python/python-oracledb/subclassing_async.py index 94f2a7ef..3d2ec024 100644 --- a/python/python-oracledb/subclassing_async.py +++ b/python/python-oracledb/subclassing_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -67,6 +67,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), conn_class=Connection, ) diff --git a/python/python-oracledb/type_handlers_json_strings.py b/python/python-oracledb/type_handlers_json_strings.py index c5fb48cc..a523cd2e 100644 --- a/python/python-oracledb/type_handlers_json_strings.py +++ b/python/python-oracledb/type_handlers_json_strings.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2022, 2023, Oracle and/or its affiliates. +# Copyright (c) 2022, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -97,6 +97,7 @@ def output_type_handler(cursor, metadata): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/type_handlers_json_strings_async.py b/python/python-oracledb/type_handlers_json_strings_async.py index e0788900..710342c3 100644 --- a/python/python-oracledb/type_handlers_json_strings_async.py +++ b/python/python-oracledb/type_handlers_json_strings_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -97,6 +97,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/type_handlers_objects.py b/python/python-oracledb/type_handlers_objects.py index 1b5af01b..903e011e 100644 --- a/python/python-oracledb/type_handlers_objects.py +++ b/python/python-oracledb/type_handlers_objects.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -49,6 +49,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) obj_type = connection.gettype("UDT_BUILDING") diff --git a/python/python-oracledb/type_handlers_objects_async.py b/python/python-oracledb/type_handlers_objects_async.py index 86924fd0..f406ace4 100644 --- a/python/python-oracledb/type_handlers_objects_async.py +++ b/python/python-oracledb/type_handlers_objects_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -63,6 +63,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) obj_type = await connection.gettype("UDT_BUILDING") diff --git a/python/python-oracledb/universal_rowids.py b/python/python-oracledb/universal_rowids.py index f4c486c1..822b0076 100644 --- a/python/python-oracledb/universal_rowids.py +++ b/python/python-oracledb/universal_rowids.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2017, 2023, Oracle and/or its affiliates. +# Copyright (c) 2017, 2024, Oracle and/or its affiliates. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -54,6 +54,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/universal_rowids_async.py b/python/python-oracledb/universal_rowids_async.py index 7181519c..0ad58876 100644 --- a/python/python-oracledb/universal_rowids_async.py +++ b/python/python-oracledb/universal_rowids_async.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -49,6 +49,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/vector.py b/python/python-oracledb/vector.py index 9d2965c8..49f90bbf 100644 --- a/python/python-oracledb/vector.py +++ b/python/python-oracledb/vector.py @@ -42,18 +42,19 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) -# this script only works with Oracle Database 23.4 or later -if sample_env.get_server_version() < (23, 4): - sys.exit("This example requires Oracle Database 23.4 or later.") +# this script only works with Oracle Database 23.5 or later +if sample_env.get_server_version() < (23, 5): + sys.exit("This example requires Oracle Database 23.5 or later.") -# this script works with thin mode, or with thick mode using Oracle Client 23.4 +# this script works with thin mode, or with thick mode using Oracle Client 23.5 # or later -if not connection.thin and oracledb.clientversion()[:2] < (23, 4): +if not connection.thin and oracledb.clientversion()[:2] < (23, 5): sys.exit( "This example requires python-oracledb thin mode, or Oracle Client" - " 23.4 or later" + " 23.5 or later" ) with connection.cursor() as cursor: @@ -61,28 +62,33 @@ vector1_data_32 = array.array("f", [1.625, 1.5, 1.0]) vector1_data_64 = array.array("d", [11.25, 11.75, 11.5]) vector1_data_8 = array.array("b", [1, 2, 3]) + vector1_data_bin = array.array("B", [180, 150, 100]) cursor.execute( - "insert into SampleVectorTab (v32, v64, v8) values (:1, :2, :3)", - [vector1_data_32, vector1_data_64, vector1_data_8], + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", + [vector1_data_32, vector1_data_64, vector1_data_8, vector1_data_bin], ) # Multi-row insert vector2_data_32 = array.array("f", [2.625, 2.5, 2.0]) vector2_data_64 = array.array("d", [22.25, 22.75, 22.5]) vector2_data_8 = array.array("b", [4, 5, 6]) + vector2_data_bin = array.array("B", [40, 15, 255]) vector3_data_32 = array.array("f", [3.625, 3.5, 3.0]) vector3_data_64 = array.array("d", [33.25, 33.75, 33.5]) vector3_data_8 = array.array("b", [7, 8, 9]) + vector3_data_bin = array.array("B", [0, 17, 101]) rows = [ - (vector2_data_32, vector2_data_64, vector2_data_8), - (vector3_data_32, vector3_data_64, vector3_data_8), + (vector2_data_32, vector2_data_64, vector2_data_8, vector2_data_bin), + (vector3_data_32, vector3_data_64, vector3_data_8, vector3_data_bin), ] cursor.executemany( - "insert into SampleVectorTab (v32, v64, v8) values (:1, :2, :3)", + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", rows, ) diff --git a/python/python-oracledb/vector_async.py b/python/python-oracledb/vector_async.py index 323ad5f7..1f349e70 100644 --- a/python/python-oracledb/vector_async.py +++ b/python/python-oracledb/vector_async.py @@ -43,39 +43,60 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) - # this script only works with Oracle Database 23.4 or later - if sample_env.get_server_version() < (23, 4): - sys.exit("This example requires Oracle Database 23.4 or later.") + # this script only works with Oracle Database 23.5 or later + if sample_env.get_server_version() < (23, 5): + sys.exit("This example requires Oracle Database 23.5 or later.") with connection.cursor() as cursor: # Single-row insert vector1_data_32 = array.array("f", [1.625, 1.5, 1.0]) vector1_data_64 = array.array("d", [11.25, 11.75, 11.5]) vector1_data_8 = array.array("b", [1, 2, 3]) + vector1_data_bin = array.array("B", [180, 150, 100]) await cursor.execute( - "insert into SampleVectorTab (v32, v64, v8) values (:1, :2, :3)", - [vector1_data_32, vector1_data_64, vector1_data_8], + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", + [ + vector1_data_32, + vector1_data_64, + vector1_data_8, + vector1_data_bin, + ], ) # Multi-row insert vector2_data_32 = array.array("f", [2.625, 2.5, 2.0]) vector2_data_64 = array.array("d", [22.25, 22.75, 22.5]) vector2_data_8 = array.array("b", [4, 5, 6]) + vector2_data_bin = array.array("B", [40, 15, 255]) vector3_data_32 = array.array("f", [3.625, 3.5, 3.0]) vector3_data_64 = array.array("d", [33.25, 33.75, 33.5]) vector3_data_8 = array.array("b", [7, 8, 9]) + vector3_data_bin = array.array("B", [0, 17, 101]) rows = [ - (vector2_data_32, vector2_data_64, vector2_data_8), - (vector3_data_32, vector3_data_64, vector3_data_8), + ( + vector2_data_32, + vector2_data_64, + vector2_data_8, + vector2_data_bin, + ), + ( + vector3_data_32, + vector3_data_64, + vector3_data_8, + vector3_data_bin, + ), ] await cursor.executemany( - "insert into SampleVectorTab (v32, v64, v8) values (:1, :2, :3)", + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", rows, ) diff --git a/python/python-oracledb/vector_numpy.py b/python/python-oracledb/vector_numpy.py index 75553483..e16a2f2d 100644 --- a/python/python-oracledb/vector_numpy.py +++ b/python/python-oracledb/vector_numpy.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -43,18 +43,19 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) -# this script only works with Oracle Database 23.4 or later -if sample_env.get_server_version() < (23, 4): - sys.exit("This example requires Oracle Database 23.4 or later.") +# this script only works with Oracle Database 23.5 or later +if sample_env.get_server_version() < (23, 5): + sys.exit("This example requires Oracle Database 23.5 or later.") -# this script works with thin mode, or with thick mode using Oracle Client 23.4 +# this script works with thin mode, or with thick mode using Oracle Client 23.5 # or later -if not connection.thin and oracledb.clientversion()[:2] < (23, 4): +if not connection.thin and oracledb.clientversion()[:2] < (23, 5): sys.exit( "This example requires python-oracledb thin mode, or Oracle Client" - " 23.4 or later" + " 23.5 or later" ) @@ -64,6 +65,8 @@ def numpy_converter_in(value): dtype = "d" elif value.dtype == numpy.float32: dtype = "f" + elif value.dtype == numpy.uint8: + dtype = "B" else: dtype = "b" return array.array(dtype, value) @@ -83,13 +86,7 @@ def input_type_handler(cursor, value, arraysize): # Convert from array types to NumPy ndarray types when fetching vectors def numpy_converter_out(value): - if value.typecode == "b": - dtype = numpy.int8 - elif value.typecode == "f": - dtype = numpy.float32 - else: - dtype = numpy.float64 - return numpy.array(value, copy=False, dtype=dtype) + return numpy.array(value, copy=False, dtype=value.typecode) def output_type_handler(cursor, metadata): @@ -106,13 +103,15 @@ def output_type_handler(cursor, metadata): with connection.cursor() as cursor: # Insert - vector_data_32 = numpy.array([1.625, 1.5, 1.0]) - vector_data_64 = numpy.array([11.25, 11.75, 11.5]) - vector_data_8 = numpy.array([1, 2, 3]) + vector_data_32 = numpy.array([1.625, 1.5, 1.0], dtype=numpy.float32) + vector_data_64 = numpy.array([11.25, 11.75, 11.5], dtype=numpy.float64) + vector_data_8 = numpy.array([1, 2, 3], dtype=numpy.int8) + vector_data_vb = numpy.array([180, 150, 100], dtype=numpy.uint8) cursor.execute( - "insert into SampleVectorTab (v32, v64, v8) values (:1, :2, :3)", - [vector_data_32, vector_data_64, vector_data_8], + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", + [vector_data_32, vector_data_64, vector_data_8, vector_data_vb], ) # Query diff --git a/python/python-oracledb/vector_numpy_async.py b/python/python-oracledb/vector_numpy_async.py index 87de54de..55afbd52 100644 --- a/python/python-oracledb/vector_numpy_async.py +++ b/python/python-oracledb/vector_numpy_async.py @@ -45,11 +45,12 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) - # this script only works with Oracle Database 23.4 or later - if sample_env.get_server_version() < (23, 4): - sys.exit("This example requires Oracle Database 23.4 or later.") + # this script only works with Oracle Database 23.5 or later + if sample_env.get_server_version() < (23, 5): + sys.exit("This example requires Oracle Database 23.5 or later.") # Convert from NumPy ndarray types to array types when inserting vectors def numpy_converter_in(value): @@ -57,6 +58,8 @@ def numpy_converter_in(value): dtype = "d" elif value.dtype == numpy.float32: dtype = "f" + elif value.dtype == numpy.uint8: + dtype = "B" else: dtype = "b" return array.array(dtype, value) @@ -73,13 +76,7 @@ def input_type_handler(cursor, value, arraysize): # Convert from array types to NumPy ndarray types when fetching vectors def numpy_converter_out(value): - if value.typecode == "b": - dtype = numpy.int8 - elif value.typecode == "f": - dtype = numpy.float32 - else: - dtype = numpy.float64 - return numpy.array(value, copy=False, dtype=dtype) + return numpy.array(value, copy=False, dtype=value.typecode) def output_type_handler(cursor, metadata): if metadata.type_code is oracledb.DB_TYPE_VECTOR: @@ -93,13 +90,15 @@ def output_type_handler(cursor, metadata): with connection.cursor() as cursor: # Insert - vector_data_32 = numpy.array([1.625, 1.5, 1.0]) - vector_data_64 = numpy.array([11.25, 11.75, 11.5]) - vector_data_8 = numpy.array([1, 2, 3]) + vector_data_32 = numpy.array([1.625, 1.5, 1.0], dtype=numpy.float32) + vector_data_64 = numpy.array([11.25, 11.75, 11.5], dtype=numpy.float64) + vector_data_8 = numpy.array([1, 2, 3], dtype=numpy.int8) + vector_data_vb = numpy.array([180, 150, 100], dtype=numpy.uint8) await cursor.execute( - "insert into SampleVectorTab (v32, v64, v8) values (:1, :2, :3)", - [vector_data_32, vector_data_64, vector_data_8], + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", + [vector_data_32, vector_data_64, vector_data_8, vector_data_vb], ) # Query diff --git a/python/python-oracledb/vector_string.py b/python/python-oracledb/vector_string.py index d937f138..b929c4bc 100644 --- a/python/python-oracledb/vector_string.py +++ b/python/python-oracledb/vector_string.py @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2023, Oracle and/or its affiliates. +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. # # This software is dual-licensed to you under the Universal Permissive License # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License @@ -43,11 +43,12 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) -# this script only works with Oracle Database 23.4 or later -if sample_env.get_server_version() < (23, 4): - sys.exit("This example requires Oracle Database 23.4 or later.") +# this script only works with Oracle Database 23.5 or later +if sample_env.get_server_version() < (23, 5): + sys.exit("This example requires Oracle Database 23.5 or later.") with connection.cursor() as cursor: @@ -55,29 +56,33 @@ vector1_data_32 = "[1.625, 1.5, 1.0]" vector1_data_64 = "[11.25, 11.75, 11.5]" vector1_data_8 = "[1, 2, 3]" + vector1_data_bin = "[180, 150, 100]" cursor.execute( - "insert into SampleVectorTab (v32, v64, v8) values (:1, :2, :3)", - [vector1_data_32, vector1_data_64, vector1_data_8], + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", + [vector1_data_32, vector1_data_64, vector1_data_8, vector1_data_bin], ) # Multi-row insert vector2_data_32 = "[2.625, 2.5, 2.0]" vector2_data_64 = "[22.25, 22.75, 22.5]" vector2_data_8 = "[4, 5, 6]" + vector2_data_bin = "[40, 15, 255]" vector3_data_32 = "[3.625, 3.5, 3.0]" vector3_data_64 = "[33.25, 33.75, 33.5]" vector3_data_8 = "[7, 8, 9]" + vector3_data_bin = "[0, 17, 101]" rows = [ - (vector2_data_32, vector2_data_64, vector2_data_8), - (vector3_data_32, vector3_data_64, vector3_data_8), + (vector2_data_32, vector2_data_64, vector2_data_8, vector2_data_bin), + (vector3_data_32, vector3_data_64, vector3_data_8, vector3_data_bin), ] cursor.executemany( - """insert into SampleVectorTab (v32, v64, v8) - values (:1, :2, :3)""", + """insert into SampleVectorTab (v32, v64, v8, vbin) + values (:1, :2, :3, :4)""", rows, ) diff --git a/python/python-oracledb/write_csv.py b/python/python-oracledb/write_csv.py index 2eb58287..dcefcb1d 100644 --- a/python/python-oracledb/write_csv.py +++ b/python/python-oracledb/write_csv.py @@ -45,6 +45,7 @@ user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: diff --git a/python/python-oracledb/write_csv_async.py b/python/python-oracledb/write_csv_async.py index 1f4c1245..e0b8d797 100644 --- a/python/python-oracledb/write_csv_async.py +++ b/python/python-oracledb/write_csv_async.py @@ -45,6 +45,7 @@ async def main(): user=sample_env.get_main_user(), password=sample_env.get_main_password(), dsn=sample_env.get_connect_string(), + params=sample_env.get_connect_params(), ) with connection.cursor() as cursor: