⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csqlrelay.c

📁 适合于Unix/Linux下的一个持久数据库连接池
💻 C
📖 第 1 页 / 共 4 页
字号:
  return Py_None;}static PyObject *getColumnType(PyObject *self, PyObject *args) {  long sqlrcur;  const char *rc="";  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnType(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnType(PyInt_AsLong(col));  }  return Py_BuildValue("s", rc);}static PyObject *getColumnLength(PyObject *self, PyObject *args) {  long sqlrcur;  uint32_t rc=0;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnLength(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnLength(PyInt_AsLong(col));  }  // FIXME: lame, python doesn't support building values from uint32_t's  return Py_BuildValue("l", (long)rc);}static PyObject *getColumnPrecision(PyObject *self, PyObject *args) {  long sqlrcur;  uint32_t rc=0;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnPrecision(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnPrecision(PyInt_AsLong(col));  }  // FIXME: lame, python doesn't support building values from uint32_t's  return Py_BuildValue("l", (long)rc);}static PyObject *getColumnScale(PyObject *self, PyObject *args) {  long sqlrcur;  uint32_t rc=0;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnScale(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnScale(PyInt_AsLong(col));  }  // FIXME: lame, python doesn't support building values from uint32_t's  return Py_BuildValue("l", (long)rc);}static PyObject *getColumnIsNullable(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsNullable(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsNullable(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getColumnIsPrimaryKey(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsPrimaryKey(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsPrimaryKey(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getColumnIsUnique(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsUnique(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsUnique(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getColumnIsPartOfKey(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsPartOfKey(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsPartOfKey(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getColumnIsUnsigned(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsUnsigned(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsUnsigned(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getColumnIsZeroFilled(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsZeroFilled(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsZeroFilled(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getColumnIsBinary(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsBinary(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsBinary(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getColumnIsAutoIncrement(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsAutoIncrement(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getColumnIsAutoIncrement(PyInt_AsLong(col));  }  return Py_BuildValue("h", (short)rc);}static PyObject *getLongest(PyObject *self, PyObject *args) {  long sqlrcur;  uint32_t rc=false;  PyObject *col;  if (!PyArg_ParseTuple(args, "lO", &sqlrcur, &col))    return NULL;  if (PyString_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getLongest(PyString_AsString(col));  } else if (PyInt_Check(col)) {    rc=((sqlrcursor *)sqlrcur)->getLongest(PyInt_AsLong(col));  }  // FIXME: lame, python doesn't support building values from uint32_t's  return Py_BuildValue("l", (long)rc);}static PyObject *getResultSetId(PyObject *self, PyObject *args) {  long sqlrcur;  uint16_t rc;  if (!PyArg_ParseTuple(args, "l", &sqlrcur))    return NULL;  rc=((sqlrcursor *)sqlrcur)->getResultSetId();  // FIXME: lame, python doesn't support building values from uint16_t's  return Py_BuildValue("h", (short)rc);}static PyObject *suspendResultSet(PyObject *self, PyObject *args) {  long sqlrcur;  if (!PyArg_ParseTuple(args, "l", &sqlrcur))    return NULL;  Py_BEGIN_ALLOW_THREADS  ((sqlrcursor *)sqlrcur)->suspendResultSet();  Py_END_ALLOW_THREADS  return Py_BuildValue("h", 0);}static PyObject *resumeResultSet(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc;  uint16_t id;  if (!PyArg_ParseTuple(args,#ifdef SUPPORTS_UNSIGNED	"lH",#else	"lh",#endif	&sqlrcur, &id))    return NULL;  Py_BEGIN_ALLOW_THREADS  rc=((sqlrcursor *)sqlrcur)->resumeResultSet(id);  Py_END_ALLOW_THREADS  return Py_BuildValue("h", (short)rc);}static PyObject *resumeCachedResultSet(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc;  uint16_t id;  char *filename;  if (!PyArg_ParseTuple(args,#ifdef SUPPORTS_UNSIGNED	"lHs",#else	"lhs",#endif	&sqlrcur, &id, &filename))    return NULL;  Py_BEGIN_ALLOW_THREADS  rc=((sqlrcursor *)sqlrcur)->resumeCachedResultSet(id,filename);  Py_END_ALLOW_THREADS  return Py_BuildValue("h", (short)rc);}static PyObject *outputBindCursorIdIsValid(PyObject *self, PyObject *args) {  long sqlrcur;  bool rc;  char *variable;  if (!PyArg_ParseTuple(args, "ls", &sqlrcur, &variable))    return NULL;  Py_BEGIN_ALLOW_THREADS  rc=((sqlrcursor *)sqlrcur)->outputBindCursorIdIsValid(variable);  Py_END_ALLOW_THREADS  return Py_BuildValue("h", (short)rc);}static PyObject *getOutputBindCursorId(PyObject *self, PyObject *args) {  long sqlrcur;  uint16_t rc;  char *variable;  if (!PyArg_ParseTuple(args, "ls", &sqlrcur, &variable))    return NULL;  Py_BEGIN_ALLOW_THREADS  rc=((sqlrcursor *)sqlrcur)->getOutputBindCursorId(variable);  Py_END_ALLOW_THREADS  // FIXME: lame, python doesn't support building values from uint16_t's  return Py_BuildValue("h", (short)rc);}static PyObject *attachToBindCursor(PyObject *self, PyObject *args) {  long sqlrcur;  uint16_t bindcursorid;  if (!PyArg_ParseTuple(args,#ifdef SUPPORTS_UNSIGNED	"lH",#else	"lh",#endif	&sqlrcur, &bindcursorid))    return NULL;  Py_BEGIN_ALLOW_THREADS  ((sqlrcursor *)sqlrcur)->attachToBindCursor(bindcursorid);  Py_END_ALLOW_THREADS  return Py_BuildValue("h", 0);}static PyMethodDef SQLRMethods[] = {  {"sqlrcon_alloc",  sqlrcon_alloc, METH_VARARGS},  {"sqlrcon_free", sqlrcon_free, METH_VARARGS},  {"endSession", endSession, METH_VARARGS},  {"suspendSession", suspendSession, METH_VARARGS},  {"getConnectionPort", getConnectionPort, METH_VARARGS},  {"getConnectionSocket", getConnectionSocket, METH_VARARGS},  {"resumeSession", resumeSession, METH_VARARGS},  {"ping", ping, METH_VARARGS},  {"identify", identify, METH_VARARGS},  {"dbVersion", dbVersion, METH_VARARGS},  {"bindFormat", bindFormat, METH_VARARGS},  {"autoCommitOn", autoCommitOn, METH_VARARGS},  {"autoCommitOff", autoCommitOff, METH_VARARGS},  {"commit", commit, METH_VARARGS},  {"rollback", rollback, METH_VARARGS},  {"debugOn", debugOn, METH_VARARGS},  {"debugOff", debugOff, METH_VARARGS},  {"getDebug", getDebug, METH_VARARGS},  {"sqlrcur_alloc",  sqlrcur_alloc, METH_VARARGS},  {"sqlrcur_free",  sqlrcur_free, METH_VARARGS},  {"setResultSetBufferSize", setResultSetBufferSize, METH_VARARGS},  {"getResultSetBufferSize", getResultSetBufferSize, METH_VARARGS},  {"dontGetColumnInfo", dontGetColumnInfo, METH_VARARGS},  {"getColumnInfo", getColumnInfo, METH_VARARGS},  {"mixedCaseColumnNames", mixedCaseColumnNames, METH_VARARGS},  {"upperCaseColumnNames", upperCaseColumnNames, METH_VARARGS},  {"lowerCaseColumnNames", lowerCaseColumnNames, METH_VARARGS},  {"cacheToFile", cacheToFile, METH_VARARGS},  {"setCacheTtl", setCacheTtl, METH_VARARGS},  {"getCacheFileName", getCacheFileName, METH_VARARGS},  {"cacheOff", cacheOff, METH_VARARGS},  {"sendQuery", sendQuery, METH_VARARGS},  {"sendQueryWithLength", sendQueryWithLength, METH_VARARGS},  {"sendFileQuery", sendFileQuery, METH_VARARGS},  {"prepareQuery", prepareQuery, METH_VARARGS},  {"prepareQueryWithLength", prepareQueryWithLength, METH_VARARGS},  {"prepareFileQuery", prepareFileQuery, METH_VARARGS},  {"substitution", substitution, METH_VARARGS},  {"substitutions", substitutions, METH_VARARGS},  {"clearBinds", clearBinds, METH_VARARGS},  {"countBindVariables", countBindVariables, METH_VARARGS},  {"inputBind", inputBind, METH_VARARGS},  {"inputBindBlob", inputBindBlob, METH_VARARGS},  {"inputBindClob", inputBindClob, METH_VARARGS},  {"inputBinds", inputBinds, METH_VARARGS},  {"defineOutputBindString", defineOutputBindString, METH_VARARGS},  {"defineOutputBindInteger", defineOutputBindInteger, METH_VARARGS},  {"defineOutputBindDouble", defineOutputBindDouble, METH_VARARGS},  {"defineOutputBindBlob", defineOutputBindBlob, METH_VARARGS},  {"defineOutputBindClob", defineOutputBindClob, METH_VARARGS},  {"defineOutputBindCursor", defineOutputBindCursor, METH_VARARGS},  {"validateBinds", validateBinds, METH_VARARGS},  {"validBind", validBind, METH_VARARGS},  {"executeQuery", executeQuery, METH_VARARGS},  {"fetchFromBindCursor", fetchFromBindCursor, METH_VARARGS},  {"getOutputBindString", getOutputBindString, METH_VARARGS},  {"getOutputBindBlob", getOutputBindBlob, METH_VARARGS},  {"getOutputBindClob", getOutputBindClob, METH_VARARGS},  {"getOutputBindInteger", getOutputBindInteger, METH_VARARGS},  {"getOutputBindDouble", getOutputBindDouble, METH_VARARGS},  {"getOutputBindLength", getOutputBindLength, METH_VARARGS},  {"openCachedResultSet", openCachedResultSet, METH_VARARGS},  {"colCount", colCount, METH_VARARGS},  {"rowCount", rowCount, METH_VARARGS},  {"totalRows", totalRows, METH_VARARGS},  {"affectedRows", affectedRows, METH_VARARGS},  {"firstRowIndex", firstRowIndex, METH_VARARGS},  {"endOfResultSet", endOfResultSet, METH_VARARGS},  {"errorMessage", errorMessage, METH_VARARGS},  {"getNullsAsEmptyStrings", getNullsAsEmptyStrings, METH_VARARGS},  {"getNullsAsNone", getNullsAsNone, METH_VARARGS},  {"getField", getField, METH_VARARGS},  {"getFieldAsInteger", getFieldAsInteger, METH_VARARGS},  {"getFieldAsDouble", getFieldAsDouble, METH_VARARGS},  {"getFieldLength", getFieldLength, METH_VARARGS},  {"getRow", getRow, METH_VARARGS},  {"getRowDictionary", getRowDictionary, METH_VARARGS},  {"getRowRange", getRowRange, METH_VARARGS},  {"getRowLengths", getRowLengths, METH_VARARGS},  {"getRowLengthsDictionary", getRowLengthsDictionary, METH_VARARGS},  {"getRowLengthsRange", getRowLengthsRange, METH_VARARGS},  {"getColumnName", getColumnName, METH_VARARGS},  {"getColumnNames", getColumnNames, METH_VARARGS},  {"getColumnType", getColumnType, METH_VARARGS},  {"getColumnLength", getColumnLength, METH_VARARGS},  {"getColumnPrecision", getColumnPrecision, METH_VARARGS},  {"getColumnScale", getColumnScale, METH_VARARGS},  {"getColumnIsNullable", getColumnIsNullable, METH_VARARGS},  {"getColumnIsPrimaryKey", getColumnIsPrimaryKey, METH_VARARGS},  {"getColumnIsUnique", getColumnIsUnique, METH_VARARGS},  {"getColumnIsPartOfKey", getColumnIsPartOfKey, METH_VARARGS},  {"getColumnIsUnsigned", getColumnIsUnsigned, METH_VARARGS},  {"getColumnIsZeroFilled", getColumnIsZeroFilled, METH_VARARGS},  {"getColumnIsBinary", getColumnIsBinary, METH_VARARGS},  {"getColumnIsAutoIncrement", getColumnIsAutoIncrement, METH_VARARGS},  {"getLongest", getLongest, METH_VARARGS},  {"getResultSetId", getResultSetId, METH_VARARGS},  {"suspendResultSet", suspendResultSet, METH_VARARGS},  {"resumeResultSet", resumeResultSet, METH_VARARGS},  {"resumeCachedResultSet", resumeCachedResultSet, METH_VARARGS},  {"outputBindCursorIdIsValid", outputBindCursorIdIsValid, METH_VARARGS},  {"getOutputBindCursorId", getOutputBindCursorId, METH_VARARGS},  {"attachToBindCursor", attachToBindCursor, METH_VARARGS},  {NULL,      NULL}        /* Sentinel */};voidinitCSQLRelay(){  (void) Py_InitModule("SQLRelay.CSQLRelay", SQLRMethods);  decimalmodule=PyImport_ImportModule("decimal");  if (decimalmodule) {    decimal=PyObject_GetAttrString(decimalmodule,"Decimal");    if (!decimal) {      PyErr_Clear();    }  } else {    PyErr_Clear();  }}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -