Added support for specifying the encodings to use for strings in the database
at the session pool level in addition to for standalone connections.
This commit is contained in:
parent
6356f78bd9
commit
2b9e80308e
@ -179,6 +179,7 @@ static int SessionPool_Init(
|
||||
int threaded, events, homogeneous, externalAuth;
|
||||
udt_Buffer username, password, dsn;
|
||||
PyTypeObject *connectionType;
|
||||
char *encoding, *nencoding;
|
||||
PyObject *externalAuthObj;
|
||||
unsigned poolNameLength;
|
||||
const char *poolName;
|
||||
@ -189,21 +190,22 @@ static int SessionPool_Init(
|
||||
// define keyword arguments
|
||||
static char *keywordList[] = { "user", "password", "dsn", "min", "max",
|
||||
"increment", "connectiontype", "threaded", "getmode", "events",
|
||||
"homogeneous", "externalauth", NULL };
|
||||
"homogeneous", "externalauth", "encoding", "nencoding", NULL };
|
||||
|
||||
// parse arguments and keywords
|
||||
homogeneous = 1;
|
||||
externalAuthObj = NULL;
|
||||
encoding = nencoding = NULL;
|
||||
threaded = events = externalAuth = 0;
|
||||
threadedObj = eventsObj = homogeneousObj = passwordObj = NULL;
|
||||
connectionType = &g_ConnectionType;
|
||||
getMode = OCI_SPOOL_ATTRVAL_NOWAIT;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "O!O!O!iii|OObOOO",
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "O!O!O!iii|OObOOOss",
|
||||
keywordList, cxString_Type, &self->username,
|
||||
cxString_Type, &passwordObj, cxString_Type, &self->dsn,
|
||||
&minSessions, &maxSessions, &sessionIncrement, &connectionType,
|
||||
&threadedObj, &getMode, &eventsObj, &homogeneousObj,
|
||||
&externalAuthObj))
|
||||
&externalAuthObj, &encoding, &nencoding))
|
||||
return -1;
|
||||
if (!PyType_Check(connectionType)) {
|
||||
PyErr_SetString(g_ProgrammingErrorException,
|
||||
@ -249,8 +251,8 @@ static int SessionPool_Init(
|
||||
self->externalAuth = externalAuth;
|
||||
|
||||
// set up the environment
|
||||
self->environment = Environment_NewFromScratch(threaded, events, NULL,
|
||||
NULL);
|
||||
self->environment = Environment_NewFromScratch(threaded, events, encoding,
|
||||
nencoding);
|
||||
if (!self->environment)
|
||||
return -1;
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ 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])
|
||||
.. function:: SessionPool(user, password, database, min, max, increment, [connectiontype, threaded, getmode=cx_Oracle.SPOOL_ATTRVAL_NOWAIT, homogeneous=True, externalauth=True, encoding=None, nencoding=None])
|
||||
|
||||
Create a session pool (see Oracle documentation for more information) and
|
||||
return a session pool object (:ref:`sesspool`). This allows for very fast
|
||||
@ -140,6 +140,12 @@ Module Interface
|
||||
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.
|
||||
|
||||
The nencoding argument is expected to be a string if specified and sets the
|
||||
national encoding to use for national character set database strings.
|
||||
|
||||
.. note::
|
||||
|
||||
This method is an extension to the DB API definition.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user