Update of /cvsroot/informixdb/informixdb/ext
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv18033
Modified Files:
_informixdb.ec
Log Message:
refactor redundant do_prepare parameters and allow cursor.execute
and .executemany to pass None to signal usage of prepared statement.
Index: _informixdb.ec
===================================================================
RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v
retrieving revision 1.77
retrieving revision 1.78
diff -C2 -d -r1.77 -r1.78
*** _informixdb.ec 3 Nov 2006 03:35:09 -0000 1.77
--- _informixdb.ec 3 Nov 2006 05:04:27 -0000 1.78
***************
*** 1778,1786 ****
}
! static PyObject *do_prepare(Cursor *self, PyObject *op, const char *sql)
{
struct sqlda *tdaIn = &self->daIn;
struct sqlda *tdaOut = self->daOut;
int i;
EXEC SQL BEGIN DECLARE SECTION;
char *queryName = self->queryName;
--- 1778,1787 ----
}
! static PyObject *do_prepare(Cursor *self, PyObject *op)
{
struct sqlda *tdaIn = &self->daIn;
struct sqlda *tdaOut = self->daOut;
int i;
+ const char *sql=NULL;
EXEC SQL BEGIN DECLARE SECTION;
char *queryName = self->queryName;
***************
*** 1792,1795 ****
--- 1793,1799 ----
require_cursor_open(self);
+ sql = PyString_AsString(op);
+ if (!sql) return NULL;
+
if (op == self->op) {
doCloseCursor(self, 0);
***************
*** 1859,1873 ****
{
PyObject *op;
- const char *sql;
static char* kwdlist[] = { "operation", 0 };
! if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwdlist, &sql))
return NULL;
- op = PyTuple_GET_ITEM(args, 0);
/* Make sure we talk to the right database. */
if (setConnection(self->conn)) return NULL;
! if (do_prepare(self, op, sql)) {
Py_INCREF(Py_None);
return Py_None;
--- 1863,1875 ----
{
PyObject *op;
static char* kwdlist[] = { "operation", 0 };
! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", kwdlist, &op))
return NULL;
/* Make sure we talk to the right database. */
if (setConnection(self->conn)) return NULL;
! if (do_prepare(self, op)) {
Py_INCREF(Py_None);
return Py_None;
***************
*** 1882,1886 ****
struct sqlda *tdaIn = &self->daIn;
PyObject *op, *inputvars=NULL;
- const char *sql;
int i;
static char* kwdlist[] = { "operation", "parameters", 0 };
--- 1884,1887 ----
***************
*** 1893,1905 ****
require_cursor_open(self);
! if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|O", kwdlist,
! &sql, &inputvars))
return NULL;
! op = PyTuple_GET_ITEM(args, 0);
!
/* Make sure we talk to the right database. */
if (setConnection(self->conn)) return NULL;
! if (!do_prepare(self, op, sql)) {
return NULL;
}
--- 1894,1907 ----
require_cursor_open(self);
! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O", kwdlist,
! &op, &inputvars))
return NULL;
! if (op==Py_None)
! op = self->op;
!
/* Make sure we talk to the right database. */
if (setConnection(self->conn)) return NULL;
! if (!do_prepare(self, op)) {
return NULL;
}
***************
*** 1949,1953 ****
struct sqlda *tdaIn = &self->daIn;
PyObject *op, *params, *paramiter, *inputvars = 0;
- const char *sql;
int i;
int rowcount = 0, inputDirty = 0, useInsertCursor;
--- 1951,1954 ----
***************
*** 1961,1967 ****
require_cursor_open(self);
! if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", kwdlist, &sql, ¶ms))
return NULL;
! op = PyTuple_GET_ITEM(args, 0);
paramiter = PyObject_GetIter(params);
if (paramiter == NULL) {
--- 1962,1969 ----
require_cursor_open(self);
! if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwdlist, &op, ¶ms))
return NULL;
! if (op==Py_None)
! op = self->op;
paramiter = PyObject_GetIter(params);
if (paramiter == NULL) {
***************
*** 1972,1976 ****
if (setConnection(self->conn)) return NULL;
! if (!do_prepare(self, op, sql)) {
return NULL;
}
--- 1974,1978 ----
if (setConnection(self->conn)) return NULL;
! if (!do_prepare(self, op)) {
return NULL;
}
|