├── .gitignore ├── LICENSE ├── LICENSE.txt ├── NOTES.md ├── README.md ├── c ├── cx_Oracle-5.1.2-dbg ├── BUILD.txt ├── Buffer.c ├── Callback.c ├── Connection.c ├── Cursor.c ├── CursorVar.c ├── DateTimeVar.c ├── Environment.c ├── Error.c ├── ExternalLobVar.c ├── ExternalObjectVar.c ├── HISTORY.txt ├── IntervalVar.c ├── LICENSE.txt ├── LobVar.c ├── LongVar.c ├── MANIFEST.in ├── NumberVar.c ├── ObjectType.c ├── ObjectVar.c ├── PKG-INFO ├── README.txt ├── SessionPool.c ├── StringVar.c ├── Subscription.c ├── TimestampVar.c ├── Transforms.c ├── Variable.c ├── c ├── cx_Oracle.c ├── html │ ├── _static │ │ ├── basic.css │ │ ├── comment-bright.png │ │ ├── comment-close.png │ │ ├── comment.png │ │ ├── default.css │ │ ├── doctools.js │ │ ├── down-pressed.png │ │ ├── down.png │ │ ├── file.png │ │ ├── jquery.js │ │ ├── minus.png │ │ ├── plus.png │ │ ├── pygments.css │ │ ├── searchtools.js │ │ ├── sidebar.js │ │ ├── underscore.js │ │ ├── up-pressed.png │ │ ├── up.png │ │ └── websupport.js │ ├── connection.html │ ├── cursor.html │ ├── genindex.html │ ├── index.html │ ├── license.html │ ├── lob.html │ ├── module.html │ ├── objects.inv │ ├── py-modindex.html │ ├── search.html │ ├── searchindex.js │ ├── session_pool.html │ ├── subscription.html │ └── variable.html ├── samples │ ├── DatabaseChangeNotification.py │ ├── DatabaseShutdown.py │ ├── DatabaseStartup.py │ ├── ReturnLongs.py │ ├── ReturnUnicode.py │ └── RowsAsInstance.py ├── setup.py └── test │ ├── 3kNumberVar.py │ ├── 3kStringVar.py │ ├── Connection.py │ ├── Cursor.py │ ├── CursorVar.py │ ├── DateTimeVar.py │ ├── IntervalVar.py │ ├── LobVar.py │ ├── LongVar.py │ ├── NumberVar.py │ ├── ObjectVar.py │ ├── SessionPool.py │ ├── SetupTest.sql │ ├── StringVar.py │ ├── TestEnv.py │ ├── TimestampVar.py │ ├── UnicodeVar.py │ ├── test.py │ ├── test3k.py │ ├── test_dbapi20.py │ ├── uConnection.py │ ├── uCursor.py │ ├── uCursorVar.py │ ├── uDateTimeVar.py │ ├── uIntervalVar.py │ ├── uLobVar.py │ ├── uLongVar.py │ ├── uNumberVar.py │ ├── uObjectVar.py │ ├── uSessionPool.py │ ├── uStringVar.py │ └── uTimestampVar.py ├── env ├── examples ├── connect │ └── flags.go ├── conntest │ ├── conn_test.go │ └── main.go └── csvdump │ ├── README.md │ └── main.go ├── godrv ├── bind_test.go ├── coldesc.go ├── driver.go ├── driver_test.go ├── lob_test.go ├── table_test.go └── var.go ├── oracle ├── connection.go ├── connection_test.go ├── cursor.go ├── cursors_test.go ├── cursorvar.go ├── datatypes_test.go ├── datetimevar.go ├── debug_notrace.go ├── debug_trace.go ├── doc.go ├── environment.go ├── error.go ├── externallobvar.go ├── lob_ctest.go ├── lob_test.go ├── lobvar.go ├── longvar.go ├── numbervar.go ├── pool.go ├── pool_test.go ├── stringvar.go ├── table_test.go └── variable.go └── rdbdrv └── driver.go /.gitignore: -------------------------------------------------------------------------------- 1 | .dsn 2 | *.test 3 | */build/* 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 Tamás Gulácsi 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgulacsi/goracle/976826e46446f186be2f7ff6343e4244817b33c9/LICENSE.txt -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- 1 | # Database Change Notification vs. Query Result Change Notification # 2 | See http://comments.gmane.org/gmane.comp.python.db.cx-oracle/2944 3 | -------------------------------------------------------------------------------- /c: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | echo fmt 4 | go fmt ./... 5 | echo vet 6 | go vet ./... 7 | if ! which golint >/dev/null; then 8 | PATH=$GOPATH/bin:$PATH 9 | if ! which golint >/dev/null; then 10 | echo 'No golint installed: to install, run' 11 | echo 'go get github.com/golang/lint/golint' 12 | exit $? 13 | fi 14 | fi 15 | set +e 16 | echo lint 17 | golint ./godrv | grep -v 'LastInsertID' 18 | golint ./oracle 19 | set -e 20 | . $(dirname $0)/env 21 | echo build 22 | go build ./... 23 | #if [ $# -ge 1 ]; then exit $?; fi 24 | #go build -tags trace ./... 25 | echo test 26 | TOPTS="${TOPTS} -test.v" 27 | if [ -n "$TRACE" ]; then 28 | TOPTS="$TOPTS -tags trace" 29 | fi 30 | rm -rf /tmp/go-build[0-9]* 31 | 32 | go test $TOPTS -work -c -tags trace ./oracle || { 33 | echo "CFLAGS=$CGO_CFLAGS LDFLAGS=$CGO_LDFLAGS" 34 | exit $? 35 | } 36 | ln -sf /tmp/go-build[0-9]* /tmp/go-build-goracle 37 | 38 | if [ -e /etc/init.d/oracle-xe ]; then 39 | if systemctl is-active oracle-xe.service; then 40 | echo 'oracle-xe is running' 41 | else 42 | sudo systemctl start oracle-xe.service 43 | while true; do 44 | if systemctl is-active oracle-xe.service; then 45 | break 46 | fi 47 | echo "waiting for Oracle" 48 | sleep 1 49 | done 50 | fi 51 | fi 52 | 53 | dsn=${DSN:-$(cat $(dirname $0)/.dsn)} 54 | 55 | go test -i ./godrv/ 56 | go test ./godrv/ -dsn="${dsn}" "$@" 57 | echo ----------------------------------------------------------------------- 58 | echo "./oracle.test -dsn=\$\(cat $(dirname $0)/.dsn\) ""$@" 59 | RECONNECTS=${RECONNECTS:-3} ./oracle.test -dsn="$dsn" "$@" 60 | 61 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/BUILD.txt: -------------------------------------------------------------------------------- 1 | Linux Build Hints 2 | ----------------- 3 | (Tested on RedHat 4.x, Gentoo 2008.0, Ubuntu 8.x, and Debian 4.x) 4 | These hints are based on using Oracle's instantclient_11_1. It is necessary 5 | to download both 'instantclient-linux-basic' and 'instantclient-sdk-linux' from 6 | oracle.com in order to successfully compile. 7 | 8 | http://www.oracle.com/technology/software/tech/oci/instantclient/index.html 9 | 10 | Each compressed tarball needs to be extracted to the exact same location. 11 | Uncompress and untar each file from the same location in order to achieve this 12 | result. If placing into a system area such as /opt or /usr/local, make sure to 13 | have the correct permissions for writing to these filesystems and/or 14 | directories. It is advisable to use the same account from start to finish while 15 | installing cx_Oracle in order not to clobber the pre-set environment variables 16 | set below. 17 | 18 | It is necessary to set environment variables ORACLE_HOME and LD_LIBRARY_PATH 19 | inside $HOME/.profile in order for cx_Oracle to import properly after 20 | installation and in order to build correctly. Using a text editor add the 21 | settings below to $HOME/.profile making sure to change the location of your 22 | actual installation path. 23 | 24 | Example ($HOME/.profile): 25 | ------------------------- 26 | export ORACLE_HOME=[your installation path]/instantclient_11_1 27 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME 28 | 29 | To put these variables into the working shell env, either source .profile 30 | (. $HOME/.profile) or execute each export statement above from a shell 31 | individually to set these variables. If these are not added to $HOME/.profile 32 | they will need to be manually set each time cx_Oracle is loaded into Python. 33 | 34 | After both packages are untarred to there installation location a link needs 35 | to be made inside the instantclient_11_1 directory. If you are using a 36 | different version of the instant client simply adjust the link per the version 37 | of libclntsh.so. 38 | 39 | Steps: 40 | ------ 41 | cd $ORACLE_HOME 42 | ln -s libclntsh.so.x.x libclntsh.so 43 | 44 | Continue to step: Building and Compilation. 45 | 46 | 47 | OS X Build Hints 48 | ---------------- 49 | (Tested on Leopard 10.5.x) 50 | The procedures for OS X are almost idential to Linux except for the package 51 | names and a few environmental caveats. For OS X it is necessary to download 52 | both 'instantclient-basic-macosx' and 'instantclient-sdk-macosx'. Download and 53 | extract each file per the build hints for Linux. 54 | 55 | For OS X it is necessary to set environment variables ORACLE_HOME, 56 | LD_LIBRARY_PATH and DYLD_LIBRARY_PATH inside $HOME/.profile and start a new 57 | shell before testing cx_Oracle. If .profile does not exist, simply create one 58 | with a text editor and add the necessary path info to these variables. 59 | 60 | Example ($HOME/.profile): 61 | ------------------------- 62 | export ORACLE_HOME=[your installation path]/instantclient_11_1 63 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME 64 | export DYLD_LIBRARY_PATH=$ORACLE_HOME 65 | 66 | The variables placed inside $HOME/.profile need to be set prior to building. 67 | Therefore, source .profile (. $HOME/.profile) or execute each export statement 68 | above from a shell individually to set these variables. Not having 69 | DYLD_LIBRARY_PATH set inside $HOME/.profile prior to building will cause a 70 | compilation error regardless of being set in the current shell's env. 71 | 72 | After both packages are untarred a link needs to be made inside the 73 | instantclient_11_1 directory. If you are using a different version of the 74 | instant client simply adjust the link per the version of libclntsh.dylib. 75 | 76 | Steps: 77 | ------ 78 | cd $ORACLE_HOME 79 | ln -s libclntsh.dylib.x.x libclntsh.dylib 80 | 81 | Continue to step: Building and Compilation. 82 | 83 | 84 | Building and Compilation 85 | ------------------------ 86 | Use the provided setup.py to build and install the module which makes use of 87 | the distutils module. Note that on Windows, I have used mingw32 88 | (http://www.mingw.org) and the module will not build with MSVC without 89 | modification. The commands required to build and install the module are as 90 | follows: 91 | 92 | python setup.py build 93 | python setup.py install 94 | 95 | 96 | Testing (Post Installation Quick Test) 97 | -------------------------------------- 98 | A very quick installation test can be performed from the command line using 99 | the Python interpreter. Below is an example of how this done. After importing 100 | cx_Oracle there should be a line containing only '>>>' which indicates the 101 | library successfully loaded. 102 | 103 | $ python 104 | Python 2.5.2 (r252:60911, Oct 25 2008, 19:37:28) 105 | [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2 106 | Type "help", "copyright", "credits" or "license" for more information. 107 | >>> import cx_Oracle 108 | >>> 109 | 110 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/Buffer.c: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Buffer.c 3 | // Defines buffer structure and routines for populating it. These are used 4 | // to translate Python objects into the buffers needed for Oracle, including 5 | // Unicode or buffer objects. 6 | //----------------------------------------------------------------------------- 7 | 8 | // define structure for abstracting string buffers 9 | typedef struct { 10 | const void *ptr; 11 | Py_ssize_t numCharacters; 12 | Py_ssize_t size; 13 | PyObject *obj; 14 | } udt_Buffer; 15 | 16 | 17 | //----------------------------------------------------------------------------- 18 | // cxBuffer_Init() 19 | // Initialize the buffer with an empty string. Returns 0 as a convenience to 20 | // the caller. 21 | //----------------------------------------------------------------------------- 22 | static int cxBuffer_Init( 23 | udt_Buffer *buf) // buffer to initialize 24 | { 25 | buf->ptr = NULL; 26 | buf->size = 0; 27 | buf->numCharacters = 0; 28 | buf->obj = NULL; 29 | return 0; 30 | } 31 | 32 | 33 | //----------------------------------------------------------------------------- 34 | // cxBuffer_Copy() 35 | // Copy the contents of the buffer. 36 | //----------------------------------------------------------------------------- 37 | static int cxBuffer_Copy( 38 | udt_Buffer *buf, // buffer to copy into 39 | udt_Buffer *copyFromBuf) // buffer to copy from 40 | { 41 | buf->ptr = copyFromBuf->ptr; 42 | buf->size = copyFromBuf->size; 43 | buf->numCharacters = copyFromBuf->numCharacters; 44 | Py_XINCREF(copyFromBuf->obj); 45 | buf->obj = copyFromBuf->obj; 46 | return 0; 47 | } 48 | 49 | 50 | //----------------------------------------------------------------------------- 51 | // cxBuffer_FromObject() 52 | // Populate the string buffer from a unicode object. 53 | //----------------------------------------------------------------------------- 54 | static int cxBuffer_FromObject( 55 | udt_Buffer *buf, // buffer to fill 56 | PyObject *obj, // object (string or Unicode object) 57 | const char *encoding) // encoding to use, if applicable 58 | { 59 | if (!obj) 60 | return cxBuffer_Init(buf); 61 | if (encoding && PyUnicode_Check(obj)) { 62 | buf->obj = PyUnicode_AsEncodedString(obj, encoding, NULL); 63 | if (!buf->obj) 64 | return -1; 65 | buf->ptr = PyBytes_AS_STRING(buf->obj); 66 | buf->size = PyBytes_GET_SIZE(buf->obj); 67 | buf->numCharacters = PyUnicode_GET_SIZE(obj); 68 | } else if (PyBytes_Check(obj)) { 69 | Py_INCREF(obj); 70 | buf->obj = obj; 71 | buf->ptr = PyBytes_AS_STRING(buf->obj); 72 | buf->size = buf->numCharacters = PyBytes_GET_SIZE(buf->obj); 73 | #if PY_MAJOR_VERSION < 3 74 | } else if (PyBuffer_Check(obj)) { 75 | if (PyObject_AsReadBuffer(obj, &buf->ptr, &buf->size) < 0) 76 | return -1; 77 | Py_INCREF(obj); 78 | buf->obj = obj; 79 | buf->numCharacters = buf->size; 80 | #endif 81 | } else { 82 | PyErr_SetString(PyExc_TypeError, CXORA_TYPE_ERROR); 83 | return -1; 84 | } 85 | return 0; 86 | } 87 | 88 | #define cxBuffer_Clear(buf) Py_XDECREF((buf)->obj) 89 | 90 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/DateTimeVar.c: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // DateTimeVar.c 3 | // Defines the routines for handling date (time) variables. 4 | //----------------------------------------------------------------------------- 5 | 6 | //----------------------------------------------------------------------------- 7 | // DateTime type 8 | //----------------------------------------------------------------------------- 9 | typedef struct { 10 | Variable_HEAD 11 | OCIDate *data; 12 | } udt_DateTimeVar; 13 | 14 | 15 | //----------------------------------------------------------------------------- 16 | // Declaration of date/time variable functions. 17 | //----------------------------------------------------------------------------- 18 | static int DateTimeVar_SetValue(udt_DateTimeVar*, unsigned, PyObject*); 19 | static PyObject *DateTimeVar_GetValue(udt_DateTimeVar*, unsigned); 20 | 21 | 22 | //----------------------------------------------------------------------------- 23 | // Python type declarations 24 | //----------------------------------------------------------------------------- 25 | static PyTypeObject g_DateTimeVarType = { 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | "cx_Oracle_dbg.DATETIME", // tp_name 28 | sizeof(udt_DateTimeVar), // tp_basicsize 29 | 0, // tp_itemsize 30 | 0, // tp_dealloc 31 | 0, // tp_print 32 | 0, // tp_getattr 33 | 0, // tp_setattr 34 | 0, // tp_compare 35 | 0, // tp_repr 36 | 0, // tp_as_number 37 | 0, // tp_as_sequence 38 | 0, // tp_as_mapping 39 | 0, // tp_hash 40 | 0, // tp_call 41 | 0, // tp_str 42 | 0, // tp_getattro 43 | 0, // tp_setattro 44 | 0, // tp_as_buffer 45 | Py_TPFLAGS_DEFAULT, // tp_flags 46 | 0 // tp_doc 47 | }; 48 | 49 | 50 | //----------------------------------------------------------------------------- 51 | // variable type declarations 52 | //----------------------------------------------------------------------------- 53 | static udt_VariableType vt_DateTime = { 54 | (InitializeProc) NULL, 55 | (FinalizeProc) NULL, 56 | (PreDefineProc) NULL, 57 | (PostDefineProc) NULL, 58 | (PreFetchProc) NULL, 59 | (IsNullProc) NULL, 60 | (SetValueProc) DateTimeVar_SetValue, 61 | (GetValueProc) DateTimeVar_GetValue, 62 | (GetBufferSizeProc) NULL, 63 | &g_DateTimeVarType, // Python type 64 | SQLT_ODT, // Oracle type 65 | SQLCS_IMPLICIT, // charset form 66 | sizeof(OCIDate), // element length (default) 67 | 0, // is character data 68 | 0, // is variable length 69 | 1, // can be copied 70 | 1 // can be in array 71 | }; 72 | 73 | 74 | static udt_VariableType vt_Date = { 75 | (InitializeProc) NULL, 76 | (FinalizeProc) NULL, 77 | (PreDefineProc) NULL, 78 | (PostDefineProc) NULL, 79 | (PreFetchProc) NULL, 80 | (IsNullProc) NULL, 81 | (SetValueProc) DateTimeVar_SetValue, 82 | (GetValueProc) DateTimeVar_GetValue, 83 | (GetBufferSizeProc) NULL, 84 | &g_DateTimeVarType, // Python type 85 | SQLT_ODT, // Oracle type 86 | SQLCS_IMPLICIT, // charset form 87 | sizeof(OCIDate), // element length (default) 88 | 0, // is character data 89 | 0, // is variable length 90 | 1, // can be copied 91 | 1 // can be in array 92 | }; 93 | 94 | 95 | //----------------------------------------------------------------------------- 96 | // DateTimeVar_SetValue() 97 | // Set the value of the variable. 98 | //----------------------------------------------------------------------------- 99 | static int DateTimeVar_SetValue( 100 | udt_DateTimeVar *var, // variable to set value for 101 | unsigned pos, // array position to set 102 | PyObject *value) // value to set 103 | { 104 | ub1 month, day, hour, minute, second; 105 | short year; 106 | 107 | if (PyDateTime_Check(value)) { 108 | year = (short) PyDateTime_GET_YEAR(value); 109 | month = PyDateTime_GET_MONTH(value); 110 | day = PyDateTime_GET_DAY(value); 111 | hour = PyDateTime_DATE_GET_HOUR(value); 112 | minute = PyDateTime_DATE_GET_MINUTE(value); 113 | second = PyDateTime_DATE_GET_SECOND(value); 114 | } else if (PyDate_Check(value)) { 115 | year = (short) PyDateTime_GET_YEAR(value); 116 | month = PyDateTime_GET_MONTH(value); 117 | day = PyDateTime_GET_DAY(value); 118 | hour = minute = second = 0; 119 | } else { 120 | PyErr_SetString(PyExc_TypeError, "expecting date data"); 121 | return -1; 122 | } 123 | 124 | // store a copy of the value 125 | OCIDateSetDate(&var->data[pos], year, month, day); 126 | OCIDateSetTime(&var->data[pos], hour, minute, second); 127 | 128 | return 0; 129 | } 130 | 131 | 132 | //----------------------------------------------------------------------------- 133 | // DateTimeVar_GetValue() 134 | // Returns the value stored at the given array position. 135 | //----------------------------------------------------------------------------- 136 | static PyObject *DateTimeVar_GetValue( 137 | udt_DateTimeVar *var, // variable to determine value for 138 | unsigned pos) // array position 139 | { 140 | return OracleDateToPythonDate(var->type, &var->data[pos]); 141 | } 142 | 143 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/Error.c: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Error.c 3 | // Error handling. 4 | //----------------------------------------------------------------------------- 5 | 6 | //----------------------------------------------------------------------------- 7 | // structure for the Python type 8 | //----------------------------------------------------------------------------- 9 | typedef struct { 10 | PyObject_HEAD 11 | sb4 code; 12 | ub4 offset; 13 | PyObject *message; 14 | const char *context; 15 | } udt_Error; 16 | 17 | 18 | //----------------------------------------------------------------------------- 19 | // forward declarations 20 | //----------------------------------------------------------------------------- 21 | static void Error_Free(udt_Error*); 22 | static PyObject *Error_Str(udt_Error*); 23 | 24 | 25 | //----------------------------------------------------------------------------- 26 | // declaration of members 27 | //----------------------------------------------------------------------------- 28 | static PyMemberDef g_ErrorMembers[] = { 29 | { "code", T_INT, offsetof(udt_Error, code), READONLY }, 30 | { "offset", T_INT, offsetof(udt_Error, offset), READONLY }, 31 | { "message", T_OBJECT, offsetof(udt_Error, message), READONLY }, 32 | { "context", T_STRING, offsetof(udt_Error, context), READONLY }, 33 | { NULL } 34 | }; 35 | 36 | 37 | //----------------------------------------------------------------------------- 38 | // declaration of Python type 39 | //----------------------------------------------------------------------------- 40 | static PyTypeObject g_ErrorType = { 41 | PyVarObject_HEAD_INIT(NULL, 0) 42 | "cx_Oracle_dbg._Error", // tp_name 43 | sizeof(udt_Error), // tp_basicsize 44 | 0, // tp_itemsize 45 | (destructor) Error_Free, // tp_dealloc 46 | 0, // tp_print 47 | 0, // tp_getattr 48 | 0, // tp_setattr 49 | 0, // tp_compare 50 | 0, // tp_repr 51 | 0, // tp_as_number 52 | 0, // tp_as_sequence 53 | 0, // tp_as_mapping 54 | 0, // tp_hash 55 | 0, // tp_call 56 | (reprfunc) Error_Str, // tp_str 57 | 0, // tp_getattro 58 | 0, // tp_setattro 59 | 0, // tp_as_buffer 60 | Py_TPFLAGS_DEFAULT, // tp_flags 61 | 0, // tp_doc 62 | 0, // tp_traverse 63 | 0, // tp_clear 64 | 0, // tp_richcompare 65 | 0, // tp_weaklistoffset 66 | 0, // tp_iter 67 | 0, // tp_iternext 68 | 0, // tp_methods 69 | g_ErrorMembers, // tp_members 70 | 0 // tp_getset 71 | }; 72 | 73 | 74 | //----------------------------------------------------------------------------- 75 | // Error_New() 76 | // Create a new error object. 77 | //----------------------------------------------------------------------------- 78 | static udt_Error *Error_New( 79 | udt_Environment *environment, // environment object 80 | const char *context, // context in which error occurred 81 | int retrieveError) // retrieve error from OCI? 82 | { 83 | char errorText[4096]; 84 | udt_Error *self; 85 | ub4 handleType; 86 | dvoid *handle; 87 | sword status; 88 | #if PY_MAJOR_VERSION >= 3 89 | Py_ssize_t len; 90 | #endif 91 | 92 | self = (udt_Error*) g_ErrorType.tp_alloc(&g_ErrorType, 0); 93 | if (!self) 94 | return NULL; 95 | self->context = context; 96 | if (retrieveError) { 97 | if (environment->errorHandle) { 98 | handle = environment->errorHandle; 99 | handleType = OCI_HTYPE_ERROR; 100 | } else { 101 | handle = environment->handle; 102 | handleType = OCI_HTYPE_ENV; 103 | } 104 | status = OCIErrorGet(handle, 1, 0, &self->code, 105 | (unsigned char*) errorText, sizeof(errorText), handleType); 106 | if (status != OCI_SUCCESS) { 107 | Py_DECREF(self); 108 | PyErr_SetString(g_InternalErrorException, "No Oracle error?"); 109 | return NULL; 110 | } 111 | #if PY_MAJOR_VERSION < 3 112 | self->message = PyBytes_FromString(errorText); 113 | #else 114 | len = strlen(errorText); 115 | self->message = PyUnicode_Decode(errorText, len, environment->encoding, 116 | NULL); 117 | #endif 118 | if (!self->message) { 119 | Py_DECREF(self); 120 | return NULL; 121 | } 122 | } 123 | 124 | return self; 125 | } 126 | 127 | 128 | //----------------------------------------------------------------------------- 129 | // Error_Free() 130 | // Deallocate the environment, disconnecting from the database if necessary. 131 | //----------------------------------------------------------------------------- 132 | static void Error_Free( 133 | udt_Error *self) // error object 134 | { 135 | Py_CLEAR(self->message); 136 | PyObject_Del(self); 137 | } 138 | 139 | 140 | //----------------------------------------------------------------------------- 141 | // Error_Str() 142 | // Return a string representation of the error variable. 143 | //----------------------------------------------------------------------------- 144 | static PyObject *Error_Str( 145 | udt_Error *self) // variable to return the string for 146 | { 147 | if (self->message) { 148 | Py_INCREF(self->message); 149 | return self->message; 150 | } 151 | return cxString_FromAscii(""); 152 | } 153 | 154 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgulacsi/goracle/976826e46446f186be2f7ff6343e4244817b33c9/cx_Oracle-5.1.2-dbg/LICENSE.txt -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include *.c 3 | include *.txt 4 | recursive-include html *.html *.js *.inv 5 | recursive-include html/_static *.png *.css *.js 6 | recursive-include samples *.py 7 | recursive-include test *.py *.sql 8 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: cx_Oracle 3 | Version: 5.1.2 4 | Summary: Python interface to Oracle 5 | Home-page: http://cx-oracle.sourceforge.net 6 | Author: Anthony Tuininga 7 | Author-email: anthony.tuininga@gmail.com 8 | License: Python Software Foundation License 9 | Description: Python interface to Oracle conforming to the Python DB API 2.0 specification. 10 | See http://www.python.org/topics/database/DatabaseAPI-2.0.html. 11 | Keywords: Oracle 12 | Platform: UNKNOWN 13 | Classifier: Development Status :: 6 - Mature 14 | Classifier: Intended Audience :: Developers 15 | Classifier: License :: OSI Approved :: Python Software Foundation License 16 | Classifier: Natural Language :: English 17 | Classifier: Operating System :: OS Independent 18 | Classifier: Programming Language :: C 19 | Classifier: Programming Language :: Python 20 | Classifier: Programming Language :: Python :: 2 21 | Classifier: Programming Language :: Python :: 3 22 | Classifier: Topic :: Database 23 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/README.txt: -------------------------------------------------------------------------------- 1 | Open Source Python/Oracle Utility - cx_Oracle 2 | --------------------------------------------- 3 | cx_Oracle is a Python extension module that allows access to Oracle and 4 | conforms to the Python database API 2.0 specifications with a number of 5 | additions. The method cursor.nextset() and the time data type are not 6 | supported by Oracle and are therefore not implemented. 7 | 8 | See http://www.python.org/topics/database/DatabaseAPI-2.0.html for more 9 | information on the Python database API specification. See the included 10 | documentation for additional information. 11 | 12 | For feedback or patches, contact Anthony Tuininga at 13 | anthony.tuininga@gmail.com. For help or to ask questions, please use the 14 | mailing list at http://lists.sourceforge.net/lists/listinfo/cx-oracle-users. 15 | 16 | Please note that an Oracle client (or server) installation is required in order 17 | to use cx_Oracle. If you do not require the tools that come with a full client 18 | installation, it is recommended to install the Instant Client which is far 19 | easier to install. 20 | 21 | 22 | Binary Install 23 | -------------- 24 | Place the file cx_Oracle.pyd or cx_Oracle.so anywhere on your Python path. 25 | 26 | 27 | Source Install 28 | -------------- 29 | This module has been built with Oracle 9.2.0, 10.2.0, 11.1.0 on Linux, 30 | Solaris and Windows. Others have reported success with other platforms 31 | such as Mac OS X. 32 | 33 | Use the provided setup.py to build and install the module which makes use of 34 | the distutils module. Note that on Windows, I have used mingw32 35 | (http://www.mingw.org) and the module will not build with MSVC without 36 | modification. The commands required to build and install the module are as 37 | follows: 38 | 39 | python setup.py build 40 | python setup.py install 41 | 42 | See BUILD.txt for additional information. 43 | 44 | 45 | Usage Example 46 | ------------- 47 | 48 | import cx_Oracle 49 | 50 | # connect via SQL*Net string or by each segment in a separate argument 51 | #connection = cx_Oracle.connect("user/password@TNS") 52 | connection = cx_Oracle.connect("user", "password", "TNS") 53 | 54 | cursor = connection.cursor() 55 | cursor.execute(""" 56 | select Col1, Col2, Col3 57 | from SomeTable 58 | where Col4 = :arg_1 59 | and Col5 between :arg_2 and :arg_3""", 60 | arg_1 = "VALUE", 61 | arg_2 = 5, 62 | arg_3 = 15) 63 | for column_1, column_2, column_3 in cursor: 64 | print "Values:", column_1, column_2, column_3 65 | 66 | 67 | For more examples, please see the test suite in the test directory and the 68 | samples in the samples directory. You can also look at the scripts in the 69 | cx_OracleTools (http://cx-oracletools.sourceforge.net) and the modules in the 70 | cx_PyOracleLib (http://cx-pyoraclelib.sourceforge.net) projects. 71 | 72 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/Transforms.c: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Transforms.c 3 | // Provides methods for transforming Oracle data to Python objects or for 4 | // setting Oracle data from Python objects. 5 | //----------------------------------------------------------------------------- 6 | 7 | static udt_VariableType vt_Date; 8 | 9 | //----------------------------------------------------------------------------- 10 | // OracleDateToPythonDate() 11 | // Return a Python date object given an Oracle date. 12 | //----------------------------------------------------------------------------- 13 | static PyObject *OracleDateToPythonDate( 14 | udt_VariableType *varType, // variable type 15 | OCIDate* value) // value to convert 16 | { 17 | ub1 hour, minute, second, month, day; 18 | sb2 year; 19 | 20 | OCIDateGetDate(value, &year, &month, &day); 21 | OCIDateGetTime(value, &hour, &minute, &second); 22 | 23 | if (varType == &vt_Date) 24 | return PyDate_FromDate(year, month, day); 25 | return PyDateTime_FromDateAndTime(year, month, day, hour, minute, second, 26 | 0); 27 | } 28 | 29 | 30 | //----------------------------------------------------------------------------- 31 | // OracleIntervalToPythonDelta() 32 | // Return a Python delta object given an Oracle interval. 33 | //----------------------------------------------------------------------------- 34 | static PyObject *OracleIntervalToPythonDelta( 35 | udt_Environment *environment, // environment 36 | OCIInterval *value) // value to convert 37 | { 38 | sb4 days, hours, minutes, seconds, fseconds; 39 | sword status; 40 | 41 | status = OCIIntervalGetDaySecond(environment->handle, 42 | environment->errorHandle, &days, &hours, &minutes, &seconds, 43 | &fseconds, value); 44 | if (Environment_CheckForError(environment, status, 45 | "OracleIntervalToPythonDelta()") < 0) 46 | return NULL; 47 | seconds = hours * 60 * 60 + minutes * 60 + seconds; 48 | return PyDelta_FromDSU(days, seconds, fseconds / 1000); 49 | } 50 | 51 | 52 | //----------------------------------------------------------------------------- 53 | // OracleTimestampToPythonDate() 54 | // Return a Python date object given an Oracle timestamp. 55 | //----------------------------------------------------------------------------- 56 | static PyObject *OracleTimestampToPythonDate( 57 | udt_Environment *environment, // environment 58 | OCIDateTime* value) // value to convert 59 | { 60 | ub1 hour, minute, second, month, day; 61 | sword status; 62 | ub4 fsecond; 63 | sb2 year; 64 | 65 | status = OCIDateTimeGetDate(environment->handle, environment->errorHandle, 66 | value, &year, &month, &day); 67 | if (Environment_CheckForError(environment, status, 68 | "OracleTimestampToPythonDate(): date portion") < 0) 69 | return NULL; 70 | status = OCIDateTimeGetTime(environment->handle, environment->errorHandle, 71 | value, &hour, &minute, &second, &fsecond); 72 | if (Environment_CheckForError(environment, status, 73 | "OracleTimestampToPythonDate(): time portion") < 0) 74 | return NULL; 75 | return PyDateTime_FromDateAndTime(year, month, day, hour, minute, second, 76 | fsecond / 1000); 77 | } 78 | 79 | 80 | //----------------------------------------------------------------------------- 81 | // OracleNumberToPythonFloat() 82 | // Return a Python date object given an Oracle date. 83 | //----------------------------------------------------------------------------- 84 | static PyObject *OracleNumberToPythonFloat( 85 | udt_Environment *environment, // environment 86 | OCINumber* value) // value to convert 87 | { 88 | double doubleValue; 89 | sword status; 90 | 91 | status = OCINumberToReal(environment->errorHandle, 92 | value, sizeof(double), (dvoid*) &doubleValue); 93 | if (Environment_CheckForError(environment, status, 94 | "OracleNumberToPythonFloat()") < 0) 95 | return NULL; 96 | return PyFloat_FromDouble(doubleValue); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /cx_Oracle-5.1.2-dbg/c: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ -f ../env ] && . ../env 3 | DSN=${1:-$(cat ../.dsn)} 4 | PYTHONPATH=build/lib.linux-x86_64-2.7-11g:$PYTHONPATH python <