From e591f92c3b520d60816063adfe5aa40248e79bf6 Mon Sep 17 00:00:00 2001 From: Blaine Carter Date: Fri, 20 Apr 2018 12:15:22 -0600 Subject: [PATCH 01/18] Modified samples and instructions to import common connection information from db_config.py or db_config.sql Changed python modules to use enviroment variables to connect. Changed .sql scripts to hand errors when droping tables and removed connect lines. --- ...Database-12c-Scripting-for-the-Future.html | 180 ++++++++++++------ samples/tutorial/aq.py | 3 +- samples/tutorial/bind_insert.py | 3 +- samples/tutorial/bind_insert.sql | 14 +- samples/tutorial/bind_query.py | 3 +- samples/tutorial/bind_sdo.py | 4 +- samples/tutorial/clob.py | 3 +- samples/tutorial/clob_string.py | 3 +- samples/tutorial/connect.py | 3 +- samples/tutorial/connect_drcp.py | 3 +- samples/tutorial/connect_pool.py | 3 +- samples/tutorial/connect_pool2.py | 5 +- samples/tutorial/db_config.py | 3 + samples/tutorial/db_config.sql | 3 + samples/tutorial/plsql_func.py | 3 +- samples/tutorial/plsql_func.sql | 12 +- samples/tutorial/plsql_proc.py | 3 +- samples/tutorial/plsql_proc.sql | 2 +- samples/tutorial/query.py | 3 +- samples/tutorial/query2.py | 3 +- samples/tutorial/query_arraysize.py | 3 +- samples/tutorial/query_arraysize.sql | 12 +- samples/tutorial/query_many.py | 3 +- samples/tutorial/query_one.py | 3 +- samples/tutorial/query_scroll.py | 3 +- samples/tutorial/rowfactory.py | 3 +- samples/tutorial/sql/GenerateManySamples.sql | 83 ++++++++ samples/tutorial/sql/SampleEnv.sql | 2 +- samples/tutorial/subclass.py | 3 +- samples/tutorial/type_converter.py | 3 +- samples/tutorial/type_input.py | 3 +- samples/tutorial/type_output.py | 3 +- samples/tutorial/versions.py | 3 +- setup.py | 35 +++- 34 files changed, 328 insertions(+), 93 deletions(-) create mode 100644 samples/tutorial/db_config.py create mode 100644 samples/tutorial/db_config.sql create mode 100644 samples/tutorial/sql/GenerateManySamples.sql diff --git a/samples/tutorial/Python-and-Oracle-Database-12c-Scripting-for-the-Future.html b/samples/tutorial/Python-and-Oracle-Database-12c-Scripting-for-the-Future.html index e5e0d425..4b1d2619 100644 --- a/samples/tutorial/Python-and-Oracle-Database-12c-Scripting-for-the-Future.html +++ b/samples/tutorial/Python-and-Oracle-Database-12c-Scripting-for-the-Future.html @@ -103,25 +103,43 @@

Preface

preconfigured with Oracle Database, Python 3.6, cx_Oracle 6.0, a text editor, and access to a terminal console.

-

To set up a similar environment yourself, install:

+

To set up a similar environment yourself, install the following required software:

- - -

It is easist to have a local pluggable database with the service - 'orclpdb' configured. If your database is not local, or has a - different service, you will need to modify the connect string in all - samples.

+
    +
  1. Python (3.6 preferred but 2.7 should work)
  2. +
  3. cx_Oracle (6.2.1 preferred any 6.x should work) and Oracle Instant Client Package - Basic (12.2 preferred 12.1 should work) +
      +
    • Linux
    • +
    • macOS - please note the special instructions for macOS in the link.
    • +
    • Windows
    • +
    +
  4. +
  5. Oracle Instant Client Package - SQL*Plus OR Oracle SQLcl
  6. +
-

To create the schema run:

+

To create the schema run:

 sqlplus sys/yoursyspassword@localhost/orclpdb as sysdba @sql/SetupSamples
 
+

Connection Information

+ +

The database connection information is set in two files: +

+

+ +

The username is "pythonhol" with + the password "welcome". The connect string is "localhost/orclpdb". + See sql/SampleEnv.sql.

+ +

It is easist to have a local pluggable database with the service + 'orclpdb' configured. If your database is not local, or has a + different service, you will need to modify the connection information in db_config.py and db_config.sql.

+

The following sections may need adjusting, depending on how you have set up your environment.

@@ -138,10 +156,6 @@

Overview

Use the Desktop icons to start editors and terminal windows.

-

A pre-created schema exists. The username is "pythonhol" with - the password "welcome". The connect string is "localhost/orclpdb". - See sql/SampleEnv.sql.

-

If you are new to Python review the Appendix: Python Primer to gain an understanding of the language.

@@ -156,11 +170,32 @@

Using Python cx_Oracle 6 with Oracle Database 12c

1. Connecting to Oracle