diff options
Diffstat (limited to 'Modules/_sqlite/clinic/module.c.h')
-rw-r--r-- | Modules/_sqlite/clinic/module.c.h | 114 |
1 files changed, 113 insertions, 1 deletions
diff --git a/Modules/_sqlite/clinic/module.c.h b/Modules/_sqlite/clinic/module.c.h index 1855735..667343d 100644 --- a/Modules/_sqlite/clinic/module.c.h +++ b/Modules/_sqlite/clinic/module.c.h @@ -2,6 +2,118 @@ preserve [clinic start generated code]*/ +PyDoc_STRVAR(pysqlite_connect__doc__, +"connect($module, /, database, timeout=5.0, detect_types=0,\n" +" isolation_level=<unrepresentable>, check_same_thread=True,\n" +" factory=ConnectionType, cached_statements=128, uri=False)\n" +"--\n" +"\n" +"Opens a connection to the SQLite database file database.\n" +"\n" +"You can use \":memory:\" to open a database connection to a database that resides\n" +"in RAM instead of on disk."); + +#define PYSQLITE_CONNECT_METHODDEF \ + {"connect", (PyCFunction)(void(*)(void))pysqlite_connect, METH_FASTCALL|METH_KEYWORDS, pysqlite_connect__doc__}, + +static PyObject * +pysqlite_connect_impl(PyObject *module, PyObject *database, double timeout, + int detect_types, PyObject *isolation_level, + int check_same_thread, PyObject *factory, + int cached_statements, int uri); + +static PyObject * +pysqlite_connect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"database", "timeout", "detect_types", "isolation_level", "check_same_thread", "factory", "cached_statements", "uri", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "connect", 0}; + PyObject *argsbuf[8]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *database; + double timeout = 5.0; + int detect_types = 0; + PyObject *isolation_level = NULL; + int check_same_thread = 1; + PyObject *factory = (PyObject*)clinic_state()->ConnectionType; + int cached_statements = 128; + int uri = 0; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 8, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_FSConverter(args[0], &database)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_CheckExact(args[1])) { + timeout = PyFloat_AS_DOUBLE(args[1]); + } + else + { + timeout = PyFloat_AsDouble(args[1]); + if (timeout == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + detect_types = _PyLong_AsInt(args[2]); + if (detect_types == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[3]) { + isolation_level = args[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[4]) { + check_same_thread = _PyLong_AsInt(args[4]); + if (check_same_thread == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[5]) { + factory = args[5]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[6]) { + cached_statements = _PyLong_AsInt(args[6]); + if (cached_statements == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + uri = PyObject_IsTrue(args[7]); + if (uri < 0) { + goto exit; + } +skip_optional_pos: + return_value = pysqlite_connect_impl(module, database, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements, uri); + +exit: + return return_value; +} + PyDoc_STRVAR(pysqlite_complete_statement__doc__, "complete_statement($module, /, statement)\n" "--\n" @@ -219,4 +331,4 @@ skip_optional: exit: return return_value; } -/*[clinic end generated code: output=e9c2442673289cab input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ef03fdbf018d3391 input=a9049054013a1b77]*/ |