1/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(pysqlite_complete_statement__doc__,
6"complete_statement($module, /, statement)\n"
7"--\n"
8"\n"
9"Checks if a string contains a complete SQL statement.");
10
11#define PYSQLITE_COMPLETE_STATEMENT_METHODDEF    \
12    {"complete_statement", _PyCFunction_CAST(pysqlite_complete_statement), METH_FASTCALL|METH_KEYWORDS, pysqlite_complete_statement__doc__},
13
14static PyObject *
15pysqlite_complete_statement_impl(PyObject *module, const char *statement);
16
17static PyObject *
18pysqlite_complete_statement(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
19{
20    PyObject *return_value = NULL;
21    static const char * const _keywords[] = {"statement", NULL};
22    static _PyArg_Parser _parser = {NULL, _keywords, "complete_statement", 0};
23    PyObject *argsbuf[1];
24    const char *statement;
25
26    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
27    if (!args) {
28        goto exit;
29    }
30    if (!PyUnicode_Check(args[0])) {
31        _PyArg_BadArgument("complete_statement", "argument 'statement'", "str", args[0]);
32        goto exit;
33    }
34    Py_ssize_t statement_length;
35    statement = PyUnicode_AsUTF8AndSize(args[0], &statement_length);
36    if (statement == NULL) {
37        goto exit;
38    }
39    if (strlen(statement) != (size_t)statement_length) {
40        PyErr_SetString(PyExc_ValueError, "embedded null character");
41        goto exit;
42    }
43    return_value = pysqlite_complete_statement_impl(module, statement);
44
45exit:
46    return return_value;
47}
48
49PyDoc_STRVAR(pysqlite_enable_shared_cache__doc__,
50"enable_shared_cache($module, /, do_enable)\n"
51"--\n"
52"\n"
53"Enable or disable shared cache mode for the calling thread.\n"
54"\n"
55"This method is deprecated and will be removed in Python 3.12.\n"
56"Shared cache is strongly discouraged by the SQLite 3 documentation.\n"
57"If shared cache must be used, open the database in URI mode using\n"
58"the cache=shared query parameter.");
59
60#define PYSQLITE_ENABLE_SHARED_CACHE_METHODDEF    \
61    {"enable_shared_cache", _PyCFunction_CAST(pysqlite_enable_shared_cache), METH_FASTCALL|METH_KEYWORDS, pysqlite_enable_shared_cache__doc__},
62
63static PyObject *
64pysqlite_enable_shared_cache_impl(PyObject *module, int do_enable);
65
66static PyObject *
67pysqlite_enable_shared_cache(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
68{
69    PyObject *return_value = NULL;
70    static const char * const _keywords[] = {"do_enable", NULL};
71    static _PyArg_Parser _parser = {NULL, _keywords, "enable_shared_cache", 0};
72    PyObject *argsbuf[1];
73    int do_enable;
74
75    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
76    if (!args) {
77        goto exit;
78    }
79    do_enable = _PyLong_AsInt(args[0]);
80    if (do_enable == -1 && PyErr_Occurred()) {
81        goto exit;
82    }
83    return_value = pysqlite_enable_shared_cache_impl(module, do_enable);
84
85exit:
86    return return_value;
87}
88
89PyDoc_STRVAR(pysqlite_register_adapter__doc__,
90"register_adapter($module, type, adapter, /)\n"
91"--\n"
92"\n"
93"Register a function to adapt Python objects to SQLite values.");
94
95#define PYSQLITE_REGISTER_ADAPTER_METHODDEF    \
96    {"register_adapter", _PyCFunction_CAST(pysqlite_register_adapter), METH_FASTCALL, pysqlite_register_adapter__doc__},
97
98static PyObject *
99pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
100                               PyObject *caster);
101
102static PyObject *
103pysqlite_register_adapter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
104{
105    PyObject *return_value = NULL;
106    PyTypeObject *type;
107    PyObject *caster;
108
109    if (!_PyArg_CheckPositional("register_adapter", nargs, 2, 2)) {
110        goto exit;
111    }
112    type = (PyTypeObject *)args[0];
113    caster = args[1];
114    return_value = pysqlite_register_adapter_impl(module, type, caster);
115
116exit:
117    return return_value;
118}
119
120PyDoc_STRVAR(pysqlite_register_converter__doc__,
121"register_converter($module, typename, converter, /)\n"
122"--\n"
123"\n"
124"Register a function to convert SQLite values to Python objects.");
125
126#define PYSQLITE_REGISTER_CONVERTER_METHODDEF    \
127    {"register_converter", _PyCFunction_CAST(pysqlite_register_converter), METH_FASTCALL, pysqlite_register_converter__doc__},
128
129static PyObject *
130pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
131                                 PyObject *callable);
132
133static PyObject *
134pysqlite_register_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
135{
136    PyObject *return_value = NULL;
137    PyObject *orig_name;
138    PyObject *callable;
139
140    if (!_PyArg_CheckPositional("register_converter", nargs, 2, 2)) {
141        goto exit;
142    }
143    if (!PyUnicode_Check(args[0])) {
144        _PyArg_BadArgument("register_converter", "argument 1", "str", args[0]);
145        goto exit;
146    }
147    if (PyUnicode_READY(args[0]) == -1) {
148        goto exit;
149    }
150    orig_name = args[0];
151    callable = args[1];
152    return_value = pysqlite_register_converter_impl(module, orig_name, callable);
153
154exit:
155    return return_value;
156}
157
158PyDoc_STRVAR(pysqlite_enable_callback_trace__doc__,
159"enable_callback_tracebacks($module, enable, /)\n"
160"--\n"
161"\n"
162"Enable or disable callback functions throwing errors to stderr.");
163
164#define PYSQLITE_ENABLE_CALLBACK_TRACE_METHODDEF    \
165    {"enable_callback_tracebacks", (PyCFunction)pysqlite_enable_callback_trace, METH_O, pysqlite_enable_callback_trace__doc__},
166
167static PyObject *
168pysqlite_enable_callback_trace_impl(PyObject *module, int enable);
169
170static PyObject *
171pysqlite_enable_callback_trace(PyObject *module, PyObject *arg)
172{
173    PyObject *return_value = NULL;
174    int enable;
175
176    enable = _PyLong_AsInt(arg);
177    if (enable == -1 && PyErr_Occurred()) {
178        goto exit;
179    }
180    return_value = pysqlite_enable_callback_trace_impl(module, enable);
181
182exit:
183    return return_value;
184}
185
186PyDoc_STRVAR(pysqlite_adapt__doc__,
187"adapt($module, obj, proto=PrepareProtocolType, alt=<unrepresentable>, /)\n"
188"--\n"
189"\n"
190"Adapt given object to given protocol.");
191
192#define PYSQLITE_ADAPT_METHODDEF    \
193    {"adapt", _PyCFunction_CAST(pysqlite_adapt), METH_FASTCALL, pysqlite_adapt__doc__},
194
195static PyObject *
196pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
197                    PyObject *alt);
198
199static PyObject *
200pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
201{
202    PyObject *return_value = NULL;
203    PyObject *obj;
204    PyObject *proto = (PyObject *)clinic_state()->PrepareProtocolType;
205    PyObject *alt = NULL;
206
207    if (!_PyArg_CheckPositional("adapt", nargs, 1, 3)) {
208        goto exit;
209    }
210    obj = args[0];
211    if (nargs < 2) {
212        goto skip_optional;
213    }
214    proto = args[1];
215    if (nargs < 3) {
216        goto skip_optional;
217    }
218    alt = args[2];
219skip_optional:
220    return_value = pysqlite_adapt_impl(module, obj, proto, alt);
221
222exit:
223    return return_value;
224}
225/*[clinic end generated code: output=ecaf4e0a239c2685 input=a9049054013a1b77]*/
226