Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5fab177f9 | ||
|
|
9311ab9c4e | ||
|
|
b03a6520d7 | ||
|
|
2a87e0f742 | ||
|
|
7426c84031 | ||
|
|
56e3491b45 | ||
|
|
3a9e66752d | ||
|
|
753cf7212d | ||
|
|
243f81fbb2 | ||
|
|
543b22f31e | ||
|
|
2153ee61b1 | ||
|
|
2ab1278917 | ||
|
|
fb7994df74 | ||
|
|
113c31edd8 | ||
|
|
6da6c42a7f | ||
|
|
f6b403ed74 | ||
|
|
73f2e39534 | ||
|
|
431a6d7ddb | ||
|
|
b3782e6094 | ||
|
|
402810aea4 |
24
CONTRIBUTING.md
Normal file
24
CONTRIBUTING.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Contributing to cx_Oracle
|
||||
|
||||
*Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.*
|
||||
|
||||
Pull requests can be made under
|
||||
[The Oracle Contributor Agreement](https://www.oracle.com/technetwork/community/oca-486395.html)
|
||||
(OCA).
|
||||
|
||||
For pull requests to be accepted into cx_Oracle, the bottom of
|
||||
your commit message must have the following line using your name and
|
||||
e-mail address as it appears in the OCA Signatories list.
|
||||
|
||||
```
|
||||
Signed-off-by: Your Name <you@example.org>
|
||||
```
|
||||
|
||||
This can be automatically added to pull requests by committing with:
|
||||
|
||||
```
|
||||
git commit --signoff
|
||||
````
|
||||
|
||||
Only pull requests from committers that can be verified as having
|
||||
signed the OCA can be accepted.
|
||||
96
README.md
Normal file
96
README.md
Normal file
@ -0,0 +1,96 @@
|
||||
# Open Source Python/Oracle Utility - cx_Oracle
|
||||
|
||||
cx_Oracle is a Python extension module that enables access to Oracle Database
|
||||
and conforms to the Python database API 2.0 specifications with a considerable
|
||||
number of additions and a couple of exclusions. The time data type is not
|
||||
supported by Oracle and is therefore not implemented. The method
|
||||
cursor.nextset() is not implemented either as the DB API specification assumes
|
||||
an implementation of cursors that does not fit well with Oracle's
|
||||
implementation of cursors and implicit results. See the method
|
||||
cursor.getimplicitresults() for more information.
|
||||
|
||||
See [PEP 249][1] for more information on the Python database API specification.
|
||||
See the [documentation][2] for a complete description of the module's
|
||||
capabilities.
|
||||
|
||||
cx_Oracle is licensed under a BSD license which you can find [here][3].
|
||||
|
||||
cx_Oracle has been tested with Python version 2.7, and with versions 3.4 and
|
||||
higher. You can use cx_Oracle with Oracle 11.2, 12.1 and 12.2 client libraries,
|
||||
allowing connection to multiple Oracle Database versions. Oracle's standard
|
||||
client-server version interoperability allows connection to both older and
|
||||
newer databases, for example Oracle 11.2 client libraries can connect to Oracle
|
||||
Database 10.2 or later.
|
||||
|
||||
Please note that an Oracle client (or server) installation is required in order
|
||||
to use cx_Oracle. If you do not require the tools that come with a full client
|
||||
installation, it is recommended to install the [Instant Client][4].
|
||||
which is far easier to install.
|
||||
|
||||
## Help
|
||||
|
||||
Issues and questions can be raised with the cx_Oracle community on
|
||||
[GitHub][9] or on the [mailing list][5].
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Binaries for some platforms are available at [PyPI][6]. If you prefer to build
|
||||
your own you can use this command
|
||||
|
||||
python -m pip install cx_Oracle
|
||||
|
||||
which will download the source package, build and install it. Otherwise, you
|
||||
can download the source package directly from PyPI, extract it and run these
|
||||
commands instead
|
||||
|
||||
python setup.py build
|
||||
python setup.py install
|
||||
|
||||
This module has been built with Oracle client 11.2, 12.1 and 12.2 on Linux and
|
||||
Windows. Others have reported success with other platforms such as macOS.
|
||||
|
||||
See [BUILD.txt][10] for additional information.
|
||||
|
||||
|
||||
## Usage Example
|
||||
|
||||
|
||||
```python
|
||||
from __future__ import print_function # needed for Python 2.x
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
# connect via SQL*Net string or by each segment in a separate argument
|
||||
#connection = cx_Oracle.connect("user/password@TNS")
|
||||
connection = cx_Oracle.connect("user", "password", "TNS")
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("""
|
||||
select Col1, Col2, Col3
|
||||
from SomeTable
|
||||
where Col4 = :arg_1
|
||||
and Col5 between :arg_2 and :arg_3""",
|
||||
arg_1 = "VALUE",
|
||||
arg_2 = 5,
|
||||
arg_3 = 15)
|
||||
for column_1, column_2, column_3 in cursor:
|
||||
print("Values:", column_1, column_2, column_3)
|
||||
```
|
||||
|
||||
|
||||
For more examples, please see the test suite in the test directory and the
|
||||
samples in the samples directory. You can also look at the scripts in the
|
||||
[cx_OracleTools][7] and the modules in the [cx_PyOracleLib][8] projects.
|
||||
|
||||
[1]: https://www.python.org/dev/peps/pep-0249
|
||||
[2]: http://cx-oracle.readthedocs.io
|
||||
[3]: https://github.com/oracle/python-cx_Oracle/blob/master/LICENSE.txt
|
||||
[4]: http://www.oracle.com/technetwork/database/features/instant-client/index.html
|
||||
[5]: http://lists.sourceforge.net/lists/listinfo/cx-oracle-users
|
||||
[6]: https://pypi.python.org/pypi/cx_Oracle
|
||||
[7]: http://cx-oracletools.sourceforge.net
|
||||
[8]: http://cx-pyoraclelib.sourceforge.net
|
||||
[9]: https://github.com/oracle/python-cx_Oracle/issues
|
||||
[10]: https://github.com/oracle/python-cx_Oracle/blob/master/BUILD.txt
|
||||
|
||||
81
README.txt
81
README.txt
@ -1,80 +1,5 @@
|
||||
Open Source Python/Oracle Utility - cx_Oracle
|
||||
---------------------------------------------
|
||||
Please see the cx_Oracle home page for links to documentation, source, build
|
||||
and installation instructions:
|
||||
|
||||
cx_Oracle is a Python extension module that allows access to Oracle and
|
||||
conforms to the Python database API 2.0 specifications with a number of
|
||||
additions. The time data type is not supported by Oracle and is therefore not
|
||||
implemented. The method cursor.nextset() is not implemented either as the DB
|
||||
API specification assumes an implementation of cursors that does not fit well
|
||||
with Oracle's implementation of cursors and implicit results. See the method
|
||||
cursor.getimplicitresults() for more information.
|
||||
|
||||
See http://www.python.org/topics/database/DatabaseAPI-2.0.html for more
|
||||
information on the Python database API specification. See the included
|
||||
documentation for additional information.
|
||||
|
||||
For feedback or patches, contact Anthony Tuininga at
|
||||
anthony.tuininga@gmail.com. For help or to ask questions, please use the
|
||||
mailing list at http://lists.sourceforge.net/lists/listinfo/cx-oracle-users.
|
||||
|
||||
Please note that an Oracle client (or server) installation is required in order
|
||||
to use cx_Oracle. If you do not require the tools that come with a full client
|
||||
installation, it is recommended to install the Instant Client which is far
|
||||
easier to install.
|
||||
|
||||
|
||||
Binary Install
|
||||
--------------
|
||||
Place the file cx_Oracle.pyd or cx_Oracle.so anywhere on your Python path.
|
||||
|
||||
|
||||
Source Install
|
||||
--------------
|
||||
This module has been built with Oracle 11g and 12c on Linux, Windows and macOS.
|
||||
Others have reported success with other platforms.
|
||||
|
||||
For simplified installation use pip
|
||||
|
||||
pip install cx_Oracle
|
||||
|
||||
Otherwise, you can use the provided setup.py to build and install the module
|
||||
|
||||
python setup.py build
|
||||
python setup.py install
|
||||
|
||||
See BUILD.txt for additional information.
|
||||
|
||||
|
||||
Usage Example
|
||||
-------------
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
# connect via SQL*Net string or by each segment in a separate argument
|
||||
#connection = cx_Oracle.connect("user/password@TNS")
|
||||
connection = cx_Oracle.connect("user", "password", "TNS")
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("""
|
||||
select Col1, Col2, Col3
|
||||
from SomeTable
|
||||
where Col4 = :arg_1
|
||||
and Col5 between :arg_2 and :arg_3""",
|
||||
arg_1 = "VALUE",
|
||||
arg_2 = 5,
|
||||
arg_3 = 15)
|
||||
for column_1, column_2, column_3 in cursor:
|
||||
print("Values:", column_1, column_2, column_3)
|
||||
|
||||
|
||||
For more examples, please see the test suite in the test directory and the
|
||||
samples in the samples directory. You can also look at the scripts in the
|
||||
cx_OracleTools (http://cx-oracletools.sourceforge.net) and the modules in the
|
||||
cx_PyOracleLib (http://cx-pyoraclelib.sourceforge.net) projects.
|
||||
|
||||
For further information see
|
||||
|
||||
http://cx-oracle.readthedocs.io
|
||||
https://oracle.github.io/python-cx_Oracle/index.html
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ master_doc = 'index'
|
||||
|
||||
# General substitutions.
|
||||
project = 'cx_Oracle'
|
||||
copyright = '2016, 2017 Oracle and/or its affiliates. All rights reserved.'
|
||||
copyright = '2016, 2017, Oracle and/or its affiliates. All rights reserved. Portions Copyright © 2007-2015, Anthony Tuininga. All rights reserved. Portions Copyright © 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta, Canada. All rights reserved'
|
||||
author = 'Oracle'
|
||||
|
||||
# The default replacements for |version| and |release|, also used in various
|
||||
|
||||
@ -87,7 +87,7 @@ Cursor Object
|
||||
refers to the return value of the function.
|
||||
|
||||
|
||||
.. method:: Cursor.callproc(name, parameters=[], keyewordParameters={})
|
||||
.. method:: Cursor.callproc(name, parameters=[], keywordParameters={})
|
||||
|
||||
Call a procedure with the given name. The sequence of parameters must
|
||||
contain one entry for each argument that the procedure expects. The result
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
Welcome to cx_Oracle's documentation!
|
||||
=====================================
|
||||
|
||||
**cx_Oracle** is a module that enables access to Oracle databases and conforms
|
||||
**cx_Oracle** is a module that enables access to Oracle Database and conforms
|
||||
to the Python database API specification. This module is currently built
|
||||
against Oracle 11.2 and 12.1 and works for both Python 2.x and 3.x.
|
||||
|
||||
@ -14,6 +14,7 @@ Contents:
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
installation.rst
|
||||
module.rst
|
||||
connection.rst
|
||||
cursor.rst
|
||||
|
||||
130
doc/src/installation.rst
Normal file
130
doc/src/installation.rst
Normal file
@ -0,0 +1,130 @@
|
||||
.. _installation:
|
||||
|
||||
************************
|
||||
cx_Oracle 5 Installation
|
||||
************************
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
Before cx_Oracle can be installed, an installation of
|
||||
`Python <https://www.python.org/downloads>`__ is needed first. Python 2.7 and
|
||||
Python 3.4 and higher are supported.
|
||||
|
||||
You must also install an Oracle Client, if that has not been done already.
|
||||
Oracle Client versions 12.2, 12.1 and 11.2 are supported. The simplest Oracle
|
||||
Client is the free `Oracle Instant Client
|
||||
<http://www.oracle.com/technetwork/database/features/instant-client/
|
||||
index.html>`__. Only the "Basic" or "Basic Light" package is required at
|
||||
run-time. If you plan to build cx_Oracle from source, you will also need the
|
||||
"SDK" package. Oracle Client libraries and the SDK are also available in any
|
||||
Oracle Database installation or full Oracle Client installation.
|
||||
|
||||
Prebuilt binaries are available on
|
||||
`PyPI <https://pypi.python.org/pypi/cx_Oracle/5.3>`__ for Windows and Linux.
|
||||
These can be downloaded and installed directly.
|
||||
|
||||
If no prebuilt binaries are available for your platform or you prefer to build
|
||||
from source you can download the source package from PyPI instead and run the
|
||||
following commands:
|
||||
|
||||
python setup.py build
|
||||
python setup.py install
|
||||
|
||||
You can also use pip, the generic tool for installing Python packages. It will
|
||||
download the source, compile and install the module for you. The command to use
|
||||
pip is the following:
|
||||
|
||||
python -m pip install cx_Oracle==5.3
|
||||
|
||||
If you run into any difficulty building from source, the
|
||||
`BUILD.txt
|
||||
<https://github.com/oracle/python-cx_Oracle/blob/v5.x/BUILD.txt>`__ file can
|
||||
be consulted for hints on how to build. The `Troubleshooting`_ section below
|
||||
may also be of help. On Linux, if cx_Oracle needs to be compiled for the
|
||||
default python package, you will need the ``python-devel`` package or
|
||||
equivalent, which provides the ``Python.h`` header file.
|
||||
|
||||
Finally, you need an `Oracle Database`_ for Python to connect to. Oracle's
|
||||
standard client-server version interoperability allows cx_Oracle to connect to
|
||||
both older and newer databases. Python can be local or remote to the database.
|
||||
|
||||
|
||||
Oracle Database
|
||||
===============
|
||||
|
||||
Oracle Client libraries allow connection to older and newer databases.
|
||||
In summary, Oracle Client 12.2 can connect to Oracle Database 11.2 or
|
||||
greater. Oracle Client 12.1 can connect to Oracle Database 10.2 or
|
||||
greater. Oracle Client 11.2 can connect to Oracle Database 9.2 or
|
||||
greater. For additional information on which Oracle Database releases
|
||||
are supported by which Oracle client versions, please see `Doc ID 207303.1
|
||||
<https://support.oracle.com/epmos/faces/DocumentDisplay?id=207303.1>`__.
|
||||
|
||||
Newer Oracle clients support new features, such as the `oraaccess.xml
|
||||
<https://docs.oracle.com/database/122/LNOCI/
|
||||
more-oci-advanced-topics.htm#LNOCI73052>`__ external configuration file
|
||||
available with 12.1 or later clients, and `session pool enhancements
|
||||
<http://docs.oracle.com/database/122/LNOCI/release-changes.htm#LNOCI005>`__
|
||||
to dead connection detection in 12.2 clients.
|
||||
|
||||
The function :func:`~cx_Oracle.clientversion()` can be used to determine
|
||||
which Oracle Client version is in use and the attribute
|
||||
:attr:`Connection.version` can be used to determine which Oracle
|
||||
Database version a connection is accessing. These can then be used to adjust
|
||||
application behavior accordingly. Attempts to use some Oracle features that are
|
||||
not supported by a particular client/server combination may result in runtime
|
||||
errors. These include:
|
||||
|
||||
- when attempting to access attributes that are not supported by the
|
||||
current Oracle Client library you will get the error "ORA-24315: illegal
|
||||
attribute type"
|
||||
|
||||
- when attempting to use implicit results with Oracle Client 11.2
|
||||
against Oracle Database 12c you will get the error "ORA-29481:
|
||||
Implicit results cannot be returned to client"
|
||||
|
||||
- when attempting to get array DML row counts with Oracle Client
|
||||
11.2 you will get the error "DPI-1013: not supported"
|
||||
|
||||
|
||||
Troubleshooting
|
||||
===============
|
||||
|
||||
If installation fails:
|
||||
|
||||
- Use option ``-v`` with pip. Review your output and logs. Try to install
|
||||
using a different method. **Google anything that looks like an error.**
|
||||
Try some potential solutions.
|
||||
|
||||
- Was there a network connection error? Do you need to see the environment
|
||||
variables ``http_proxy`` and/or ``https_proxy``?
|
||||
|
||||
- Do you get the error "``No module named pip``"? The pip module is builtin
|
||||
to Python from version 2.7.9 but is sometimes removed by the OS. Use the
|
||||
venv module (builtin to Python 3.x) or virtualenv module (Python 2.x)
|
||||
instead.
|
||||
|
||||
If importing cx_Oracle fails:
|
||||
|
||||
- Check the ``PATH`` environment variable on Windows. Ensure that you
|
||||
have restarted your command prompt if you have modified environment
|
||||
variables.
|
||||
- Check the ``LD_LIBRARY_PATH`` environment variable on Linux.
|
||||
- On macOS, make sure Oracle Instant Client is in `~/lib` or
|
||||
`/usr/local/lib` and that you are not using the bundled Python (use
|
||||
`Homebrew <https://brew.sh>`__ or `Python.org
|
||||
<https://www.python.org/downloads>`__ instead).
|
||||
- Check that Python, cx_Oracle and your Oracle Client libraries are all
|
||||
64-bit or all 32-bit.
|
||||
- on Windows, check that the correct Windows redistributables have been
|
||||
installed.
|
||||
|
||||
- 11.2 : `VS 2005 64-bit <https://www.microsoft.com/en-us/download/details.aspx?id=18471>`__ or `VS 2005 32-bit <https://www.microsoft.com/en-ca/download/details.aspx?id=3387>`__
|
||||
- 12.1 : `VS 2010 <https://support.microsoft.com/en-us/kb/2977003#bookmark-vs2010>`__
|
||||
- 12.2 : `VS 2013 <https://support.microsoft.com/en-us/kb/2977003#bookmark-vs2013>`__
|
||||
|
||||
- If you have both Python 2 and 3 installed, make sure you are
|
||||
using the correct python and pip (or python3 and pip3)
|
||||
executables.
|
||||
|
||||
@ -132,18 +132,21 @@ Module Interface
|
||||
This method is an extension to the DB API definition.
|
||||
|
||||
|
||||
.. function:: SessionPool(user, password, database, min, max, increment, [connectiontype, threaded, getmode=cx_Oracle.SPOOL_ATTRVAL_NOWAIT, homogeneous=True, externalauth=True, encoding=None, nencoding=None])
|
||||
.. function:: SessionPool(user, password, database, min, max, increment, [connectiontype=cx_Oracle.Connection, threaded=False, getmode=cx_Oracle.SPOOL_ATTRVAL_NOWAIT, homogeneous=True, externalauth=False, encoding=None, nencoding=None])
|
||||
|
||||
Create and return a :ref:`session pool object <sesspool>`. This
|
||||
allows for very fast connections to the database and is of primary use in a
|
||||
server where the same connection is being made multiple times in rapid
|
||||
succession (a web server, for example). If the connection type is specified,
|
||||
all calls to acquire() will create connection objects of that type, rather
|
||||
than the base type defined at the module level. The threaded attribute is
|
||||
expected to be a boolean expression which indicates whether Oracle should
|
||||
wrap accesses to connections with a mutex. Doing so in single threaded
|
||||
applications imposes a performance penalty of about 10-15% which is why the
|
||||
default is False.
|
||||
succession (a web server, for example).
|
||||
|
||||
If the connection type is specified, all calls to acquire() will create
|
||||
connection objects of that type, rather than the base type defined at the
|
||||
module level.
|
||||
|
||||
The threaded attribute is expected to be a boolean expression which
|
||||
indicates whether Oracle should wrap accesses to connections with a mutex.
|
||||
Doing so in single threaded applications imposes a performance penalty of
|
||||
about 10-15% which is why the default is False.
|
||||
|
||||
The encoding argument is expected to be a string if specified and sets the
|
||||
encoding to use for regular database strings.
|
||||
|
||||
@ -8,6 +8,12 @@ Release notes
|
||||
Version 5.next
|
||||
--------------
|
||||
|
||||
Version 5.3.1 (TBD)
|
||||
-------------------
|
||||
|
||||
1) Added support for smallint and float data types in Oracle objects, as
|
||||
requested (https://github.com/oracle/python-cx_Oracle/issues/4).
|
||||
|
||||
|
||||
Version 5.3 (March 2017)
|
||||
------------------------
|
||||
|
||||
@ -9,11 +9,21 @@ SessionPool Object
|
||||
This object is an extension to the DB API.
|
||||
|
||||
|
||||
.. method:: SessionPool.acquire()
|
||||
.. method:: SessionPool.acquire(user=None, password=None, cclass=None, purity=cx_Oracle.ATTR_PURITY_DEFAULT)
|
||||
|
||||
Acquire a connection from the session pool and return a
|
||||
:ref:`connection object <connobj>`.
|
||||
|
||||
The user and password arguments may not be specified if the pool is
|
||||
homogeneous. In that case an exception will be raised.
|
||||
|
||||
The cclass argument, if specified, should be a string corresponding to the
|
||||
connection class for database resident connection pooling (DRCP).
|
||||
|
||||
The purity argument is expected to be one of
|
||||
:data:`~cx_Oracle.ATTR_PURITY_NEW`, :data:`~cx_Oracle.ATTR_PURITY_SELF`, or
|
||||
:data:`~cx_Oracle.ATTR_PURITY_DEFAULT`.
|
||||
|
||||
|
||||
.. attribute:: SessionPool.busy
|
||||
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# AdvancedQueuing.py
|
||||
# This script demonstrates how to use advanced queuing using cx_Oracle. It
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# AppContext.py
|
||||
# This script demonstrates the use of application context. Application
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# DRCP.py
|
||||
# This script demonstrates the use of Database Resident Connection Pooling
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# DatabaseChangeNotification.py
|
||||
# This script demonstrates using database change notification in Python, a
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# DatabaseShutdown.py
|
||||
# This script demonstrates shutting down a database using Python. It is only
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# DatabaseStartup.py
|
||||
# This script demonstrates starting up a database using Python. It is only
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Editioning.py
|
||||
# This script demonstrates the use of editioning, available in Oracle
|
||||
|
||||
49
samples/ImplicitResults.py
Normal file
49
samples/ImplicitResults.py
Normal file
@ -0,0 +1,49 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# ImplicitResults.py
|
||||
# This script demonstrates the use of the 12.1 feature that allows PL/SQL
|
||||
# procedures to return result sets implicitly, without having to explicitly
|
||||
# define them.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
con = cx_Oracle.connect("cx_Oracle/dev@localhost/orcl")
|
||||
cur = con.cursor()
|
||||
|
||||
# use PL/SQL block to return two cursors
|
||||
cur.execute("""
|
||||
declare
|
||||
c1 sys_refcursor;
|
||||
c2 sys_refcursor;
|
||||
begin
|
||||
|
||||
open c1 for
|
||||
select * from TestNumbers;
|
||||
|
||||
dbms_sql.return_result(c1);
|
||||
|
||||
open c2 for
|
||||
select * from TestStrings;
|
||||
|
||||
dbms_sql.return_result(c2);
|
||||
|
||||
end;""")
|
||||
|
||||
# display results
|
||||
for ix, resultSet in enumerate(cur.getimplicitresults()):
|
||||
print("Result Set #" + str(ix + 1))
|
||||
for row in resultSet:
|
||||
print(row)
|
||||
print()
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# InsertGeometry.py
|
||||
# This script demonstrates the ability to create Oracle objects (this example
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# QueryChangeNotification.py
|
||||
# This script demonstrates using query change notification in Python, a
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# ReturnLongs.py
|
||||
# Returns all CLOB values as long strings and BLOB values as long raws. This
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# ReturnUnicode.py
|
||||
# Returns all strings as unicode. This also demonstrates the use of an output
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# RowsAsInstance.py
|
||||
# Returns rows as instances instead of tuples. See the ceDatabase.Row class
|
||||
|
||||
70
samples/ScrollableCursors.py
Normal file
70
samples/ScrollableCursors.py
Normal file
@ -0,0 +1,70 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# ScrollableCursors.py
|
||||
# This script demonstrates how to use scrollable cursors. These allow moving
|
||||
# forward and backward in the result set but incur additional overhead on the
|
||||
# server to retain this information.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
con = cx_Oracle.connect("cx_Oracle/dev@localhost/orcl")
|
||||
|
||||
# show all of the rows available in the table
|
||||
cur = con.cursor()
|
||||
cur.execute("select * from TestStrings order by IntCol")
|
||||
print("ALL ROWS")
|
||||
for row in cur:
|
||||
print(row)
|
||||
print()
|
||||
|
||||
# create a scrollable cursor
|
||||
cur = con.cursor(scrollable = True)
|
||||
|
||||
# set array size smaller than the default (100) to force scrolling by the
|
||||
# database; otherwise, scrolling occurs directly within the buffers
|
||||
cur.arraysize = 3
|
||||
cur.execute("select * from TestStrings order by IntCol")
|
||||
|
||||
# scroll to last row in the result set; the first parameter is not needed and
|
||||
# is ignored)
|
||||
cur.scroll(mode = "last")
|
||||
print("LAST ROW")
|
||||
print(cur.fetchone())
|
||||
print()
|
||||
|
||||
# scroll to the first row in the result set; the first parameter not needed and
|
||||
# is ignored
|
||||
cur.scroll(mode = "first")
|
||||
print("FIRST ROW")
|
||||
print(cur.fetchone())
|
||||
print()
|
||||
|
||||
# scroll to an absolute row number
|
||||
cur.scroll(5, mode = "absolute")
|
||||
print("ROW 5")
|
||||
print(cur.fetchone())
|
||||
print()
|
||||
|
||||
# scroll forward six rows (the mode parameter defaults to relative)
|
||||
cur.scroll(3)
|
||||
print("SKIP 3 ROWS")
|
||||
print(cur.fetchone())
|
||||
print()
|
||||
|
||||
# scroll backward four rows (the mode parameter defaults to relative)
|
||||
cur.scroll(-4)
|
||||
print("SKIP BACK 4 ROWS")
|
||||
print(cur.fetchone())
|
||||
print()
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# TransactionGuard.py
|
||||
# This script demonstrates the use of Transaction Guard to verify if a
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# TypeHandlers.py
|
||||
# This script demonstrates the use of input and output type handlers as well
|
||||
|
||||
6
setup.py
6
setup.py
@ -380,12 +380,12 @@ setup(
|
||||
cmdclass = commandClasses,
|
||||
options = dict(bdist_rpm = dict(doc_files = docFiles)),
|
||||
long_description = \
|
||||
"Python interface to Oracle conforming to the Python DB API 2.0 "
|
||||
"specification.\n"
|
||||
"Python interface to Oracle Database conforming to the Python DB "
|
||||
"API 2.0 specification.\n"
|
||||
"See http://www.python.org/topics/database/DatabaseAPI-2.0.html.",
|
||||
author = "Anthony Tuininga",
|
||||
author_email = "anthony.tuininga@gmail.com",
|
||||
url = "http://cx-oracle.sourceforge.net",
|
||||
url = "https://oracle.github.io/python-cx_Oracle",
|
||||
ext_modules = [extension],
|
||||
keywords = "Oracle",
|
||||
license = "BSD License",
|
||||
|
||||
@ -1643,7 +1643,7 @@ static PyObject *Connection_NewCursor(
|
||||
PyObject *args, // arguments
|
||||
PyObject *keywordArgs) // keyword arguments
|
||||
{
|
||||
PyObject *createArgs, *result;
|
||||
PyObject *createArgs, *result, *arg;
|
||||
Py_ssize_t numArgs = 0, i;
|
||||
|
||||
if (args)
|
||||
@ -1653,8 +1653,11 @@ static PyObject *Connection_NewCursor(
|
||||
return NULL;
|
||||
Py_INCREF(self);
|
||||
PyTuple_SET_ITEM(createArgs, 0, (PyObject*) self);
|
||||
for (i = 0; i < numArgs; i++)
|
||||
PyTuple_SET_ITEM(createArgs, i + 1, PyTuple_GET_ITEM(args, i));
|
||||
for (i = 0; i < numArgs; i++) {
|
||||
arg = PyTuple_GET_ITEM(args, i);
|
||||
Py_INCREF(arg);
|
||||
PyTuple_SET_ITEM(createArgs, i + 1, arg);
|
||||
}
|
||||
result = PyObject_Call( (PyObject*) &g_CursorType, createArgs,
|
||||
keywordArgs);
|
||||
Py_DECREF(createArgs);
|
||||
|
||||
@ -20,6 +20,7 @@ typedef struct {
|
||||
OCIStmt **data;
|
||||
udt_Connection *connection;
|
||||
PyObject *cursors;
|
||||
int createCursors;
|
||||
} udt_CursorVar;
|
||||
|
||||
|
||||
@ -30,6 +31,7 @@ static int CursorVar_Initialize(udt_CursorVar*, udt_Cursor*);
|
||||
static void CursorVar_Finalize(udt_CursorVar*);
|
||||
static int CursorVar_SetValue(udt_CursorVar*, unsigned, PyObject*);
|
||||
static PyObject *CursorVar_GetValue(udt_CursorVar*, unsigned);
|
||||
static int CursorVar_PreFetch(udt_CursorVar*);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -69,7 +71,7 @@ static udt_VariableType vt_Cursor = {
|
||||
(PreDefineProc) NULL,
|
||||
(PostDefineProc) NULL,
|
||||
(PostBindProc) NULL,
|
||||
(PreFetchProc) NULL,
|
||||
(PreFetchProc) CursorVar_PreFetch,
|
||||
(IsNullProc) NULL,
|
||||
(SetValueProc) CursorVar_SetValue,
|
||||
(GetValueProc) CursorVar_GetValue,
|
||||
@ -99,6 +101,7 @@ static int CursorVar_Initialize(
|
||||
Py_INCREF(cursor->connection);
|
||||
var->connection = cursor->connection;
|
||||
var->cursors = PyList_New(var->allocatedElements);
|
||||
var->createCursors = 0;
|
||||
if (!var->cursors)
|
||||
return -1;
|
||||
for (i = 0; i < var->allocatedElements; i++) {
|
||||
@ -127,8 +130,8 @@ static int CursorVar_Initialize(
|
||||
static void CursorVar_Finalize(
|
||||
udt_CursorVar *var) // variable to free
|
||||
{
|
||||
Py_DECREF(var->connection);
|
||||
Py_XDECREF(var->cursors);
|
||||
Py_CLEAR(var->connection);
|
||||
Py_CLEAR(var->cursors);
|
||||
}
|
||||
|
||||
|
||||
@ -181,3 +184,41 @@ static PyObject *CursorVar_GetValue(
|
||||
return cursor;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CursorVar_PreFetch()
|
||||
// Clear cursors and create new ones in preparation for next fetch.
|
||||
//-----------------------------------------------------------------------------
|
||||
static int CursorVar_PreFetch(
|
||||
udt_CursorVar *var) // variable to free
|
||||
{
|
||||
udt_Cursor *tempCursor;
|
||||
ub4 i;
|
||||
|
||||
// do not clear cursors the first time (already created by initialize)
|
||||
if (!var->createCursors) {
|
||||
var->createCursors = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// clear original cursors and create new ones
|
||||
for (i = 0; i < var->allocatedElements; i++) {
|
||||
|
||||
// clear original cursor, if applicable
|
||||
Py_CLEAR(PyList_GET_ITEM(var->cursors, i));
|
||||
var->data[i] = NULL;
|
||||
|
||||
// create new cursor
|
||||
tempCursor = (udt_Cursor*) Connection_NewCursor(var->connection, NULL,
|
||||
NULL);
|
||||
if (!tempCursor)
|
||||
return -1;
|
||||
PyList_SET_ITEM(var->cursors, i, (PyObject*) tempCursor);
|
||||
if (Cursor_AllocateHandle(tempCursor) < 0)
|
||||
return -1;
|
||||
var->data[i] = tempCursor->handle;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -425,9 +425,11 @@ static PyObject *Object_ConvertToPython(
|
||||
return cxString_FromEncodedString( (char*) stringValue,
|
||||
stringSize, environment->encoding);
|
||||
case OCI_TYPECODE_INTEGER:
|
||||
case OCI_TYPECODE_SMALLINT:
|
||||
return OracleNumberToPythonInteger(environment,
|
||||
(OCINumber*) value);
|
||||
case OCI_TYPECODE_NUMBER:
|
||||
case OCI_TYPECODE_FLOAT:
|
||||
return OracleNumberToPythonFloat(environment, (OCINumber*) value);
|
||||
case OCI_TYPECODE_DATE:
|
||||
return OracleDateToPythonDate(&vt_DateTime, (OCIDate*) value);
|
||||
|
||||
@ -248,6 +248,12 @@ static int PythonFloatToOracleNumber(
|
||||
sword status;
|
||||
|
||||
doubleValue = PyFloat_AS_DOUBLE(pythonValue);
|
||||
if (isnan(doubleValue)) {
|
||||
PyErr_SetString(g_DatabaseErrorException,
|
||||
"value is not a number (NaN) and cannot be used in Oracle "
|
||||
"numbers");
|
||||
return -1;
|
||||
}
|
||||
status = OCINumberFromReal(environment->errorHandle, &doubleValue,
|
||||
sizeof(double), oracleValue);
|
||||
return Environment_CheckForError(environment, status,
|
||||
|
||||
@ -18,10 +18,18 @@
|
||||
#include <datetime.h>
|
||||
#include <structmember.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <oci.h>
|
||||
#include <orid.h>
|
||||
#include <xa.h>
|
||||
|
||||
// define isnan for older versions of Visual Studio which only define _isnan
|
||||
#ifdef _WIN32
|
||||
#ifndef isnan
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// validate OCI library
|
||||
#if !defined(OCI_MAJOR_VERSION) || (OCI_MAJOR_VERSION < 11) || \
|
||||
((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing boolean variables."""
|
||||
|
||||
class TestBooleanVar(BaseTestCase):
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing connections."""
|
||||
|
||||
import threading
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing cursor objects."""
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing cursor variables."""
|
||||
|
||||
import sys
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing date/time variables."""
|
||||
|
||||
import datetime
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing error objects."""
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing features introduced in 12.1"""
|
||||
|
||||
import datetime
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing interval variables."""
|
||||
|
||||
import datetime
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing LOB (CLOB and BLOB) variables."""
|
||||
|
||||
import sys
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing long and long raw variables."""
|
||||
|
||||
import sys
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing NCHAR variables."""
|
||||
|
||||
class TestNCharVar(BaseTestCase):
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing number variables."""
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing object variables."""
|
||||
|
||||
import cx_Oracle
|
||||
@ -102,14 +111,14 @@ class TestObjectVar(BaseTestCase):
|
||||
[ ('INTCOL', cx_Oracle.NUMBER, 10, None, 9, 0, 0),
|
||||
('OBJECTCOL', cx_Oracle.OBJECT, None, None, None, None, 1),
|
||||
('ARRAYCOL', cx_Oracle.OBJECT, None, None, None, None, 1) ])
|
||||
self.__TestData(1, (1, 'First row', 'First ',
|
||||
self.__TestData(1, (1, 'First row', 'First ', 2, 5, 12.5,
|
||||
cx_Oracle.Timestamp(2007, 3, 6, 0, 0, 0),
|
||||
cx_Oracle.Timestamp(2008, 9, 12, 16, 40),
|
||||
(11, 'Sub object 1'),
|
||||
[(5, 'first element'), (6, 'second element')]),
|
||||
[5, 10, None, 20])
|
||||
self.__TestData(2, None, [3, None, 9, 12, 15])
|
||||
self.__TestData(3, (3, 'Third row', 'Third ',
|
||||
self.__TestData(3, (3, 'Third row', 'Third ', 4, 10, 43.25,
|
||||
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
|
||||
cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45),
|
||||
(13, 'Sub object 3'),
|
||||
@ -123,8 +132,9 @@ class TestObjectVar(BaseTestCase):
|
||||
self.assertEqual(typeObj.schema, self.connection.username.upper())
|
||||
self.assertEqual(typeObj.name, "UDT_OBJECT")
|
||||
expectedAttributeNames = ["NUMBERVALUE", "STRINGVALUE",
|
||||
"FIXEDCHARVALUE", "DATEVALUE", "TIMESTAMPVALUE",
|
||||
"SUBOBJECTVALUE", "SUBOBJECTARRAY"]
|
||||
"FIXEDCHARVALUE", "INTVALUE", "SMALLINTVALUE", "FLOATVALUE",
|
||||
"DATEVALUE", "TIMESTAMPVALUE", "SUBOBJECTVALUE",
|
||||
"SUBOBJECTARRAY"]
|
||||
actualAttributeNames = [a.name for a in typeObj.attributes]
|
||||
self.assertEqual(actualAttributeNames, expectedAttributeNames)
|
||||
typeObj = self.connection.gettype("UDT_OBJECTARRAY")
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing session pools."""
|
||||
|
||||
import threading
|
||||
|
||||
@ -56,6 +56,9 @@ create type cx_Oracle.udt_Object as object (
|
||||
NumberValue number,
|
||||
StringValue varchar2(60),
|
||||
FixedCharValue char(10),
|
||||
IntValue integer,
|
||||
SmallIntValue smallint,
|
||||
FloatValue float,
|
||||
DateValue date,
|
||||
TimestampValue timestamp,
|
||||
SubObjectValue cx_Oracle.udt_SubObject,
|
||||
@ -272,7 +275,7 @@ end;
|
||||
/
|
||||
|
||||
insert into cx_Oracle.TestObjects values (1,
|
||||
cx_Oracle.udt_Object(1, 'First row', 'First',
|
||||
cx_Oracle.udt_Object(1, 'First row', 'First', 2, 5, 12.5,
|
||||
to_date(20070306, 'YYYYMMDD'),
|
||||
to_timestamp('20080912 16:40:00', 'YYYYMMDD HH24:MI:SS'),
|
||||
cx_Oracle.udt_SubObject(11, 'Sub object 1'),
|
||||
@ -285,7 +288,7 @@ insert into cx_Oracle.TestObjects values (2, null,
|
||||
cx_Oracle.udt_Array(3, null, 9, 12, 15));
|
||||
|
||||
insert into cx_Oracle.TestObjects values (3,
|
||||
cx_Oracle.udt_Object(3, 'Third row', 'Third',
|
||||
cx_Oracle.udt_Object(3, 'Third row', 'Third', 4, 10, 43.25,
|
||||
to_date(20070621, 'YYYYMMDD'),
|
||||
to_timestamp('20071213 07:30:45', 'YYYYMMDD HH24:MI:SS'),
|
||||
cx_Oracle.udt_SubObject(13, 'Sub object 3'),
|
||||
|
||||
@ -1,4 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing string variables."""
|
||||
|
||||
class TestStringVar(BaseTestCase):
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Define test environment."""
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing timestamp variables."""
|
||||
|
||||
import time
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Runs all defined unit tests."""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Driver specific portion of the DB API test suite provided by Stuart Bishop
|
||||
available at http://stuartbishop.net/Software/DBAPI20TestSuite/"""
|
||||
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing connections."""
|
||||
|
||||
import threading
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing cursor objects."""
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing cursor variables."""
|
||||
|
||||
import sys
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing date/time variables."""
|
||||
|
||||
import datetime
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing row count per iteration for DML Array and Batch errors"""
|
||||
|
||||
class TestArrayDMLBatchError(BaseTestCase):
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing interval variables."""
|
||||
|
||||
import datetime
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing LOB (CLOB and BLOB) variables."""
|
||||
|
||||
class TestLobVar(BaseTestCase):
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing long and long raw variables."""
|
||||
|
||||
class TestLongVar(BaseTestCase):
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing number variables."""
|
||||
|
||||
import cx_Oracle
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing object variables."""
|
||||
|
||||
import cx_Oracle
|
||||
@ -45,14 +54,14 @@ class TestObjectVar(BaseTestCase):
|
||||
[ (u'INTCOL', cx_Oracle.NUMBER, 10, None, 9, 0, 0),
|
||||
(u'OBJECTCOL', cx_Oracle.OBJECT, None, None, None, None, 1),
|
||||
(u'ARRAYCOL', cx_Oracle.OBJECT, None, None, None, None, 1) ])
|
||||
self.__TestData(1, (1, u'First row', u'First ',
|
||||
self.__TestData(1, (1, u'First row', u'First ', 2, 5, 12.5,
|
||||
cx_Oracle.Timestamp(2007, 3, 6, 0, 0, 0),
|
||||
cx_Oracle.Timestamp(2008, 9, 12, 16, 40),
|
||||
(11, 'Sub object 1'),
|
||||
[(5, 'first element'), (6, 'second element')]),
|
||||
[5, 10, None, 20])
|
||||
self.__TestData(2, None, [3, None, 9, 12, 15])
|
||||
self.__TestData(3, (3, u'Third row', u'Third ',
|
||||
self.__TestData(3, (3, u'Third row', u'Third ', 4, 10, 43.25,
|
||||
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
|
||||
cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45),
|
||||
(13, 'Sub object 3'),
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing session pools."""
|
||||
|
||||
import threading
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing string variables."""
|
||||
|
||||
class TestStringVar(BaseTestCase):
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
||||
#
|
||||
# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta,
|
||||
# Canada. All rights reserved.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
"""Module for testing timestamp variables."""
|
||||
|
||||
import time
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user