1 | /*[clinic input] |
2 | preserve |
3 | [clinic start generated code]*/ |
4 | |
5 | PyDoc_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)(void(*)(void))pysqlite_complete_statement, METH_FASTCALL|METH_KEYWORDS, pysqlite_complete_statement__doc__}, |
13 | |
14 | static PyObject * |
15 | pysqlite_complete_statement_impl(PyObject *module, const char *statement); |
16 | |
17 | static PyObject * |
18 | pysqlite_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 | |
45 | exit: |
46 | return return_value; |
47 | } |
48 | |
49 | PyDoc_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)(void(*)(void))pysqlite_enable_shared_cache, METH_FASTCALL|METH_KEYWORDS, pysqlite_enable_shared_cache__doc__}, |
62 | |
63 | static PyObject * |
64 | pysqlite_enable_shared_cache_impl(PyObject *module, int do_enable); |
65 | |
66 | static PyObject * |
67 | pysqlite_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 | |
85 | exit: |
86 | return return_value; |
87 | } |
88 | |
89 | PyDoc_STRVAR(pysqlite_register_adapter__doc__, |
90 | "register_adapter($module, type, caster, /)\n" |
91 | "--\n" |
92 | "\n" |
93 | "Registers an adapter with sqlite3\'s adapter registry." ); |
94 | |
95 | #define PYSQLITE_REGISTER_ADAPTER_METHODDEF \ |
96 | {"register_adapter", (PyCFunction)(void(*)(void))pysqlite_register_adapter, METH_FASTCALL, pysqlite_register_adapter__doc__}, |
97 | |
98 | static PyObject * |
99 | pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type, |
100 | PyObject *caster); |
101 | |
102 | static PyObject * |
103 | pysqlite_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 | |
116 | exit: |
117 | return return_value; |
118 | } |
119 | |
120 | PyDoc_STRVAR(pysqlite_register_converter__doc__, |
121 | "register_converter($module, name, converter, /)\n" |
122 | "--\n" |
123 | "\n" |
124 | "Registers a converter with sqlite3." ); |
125 | |
126 | #define PYSQLITE_REGISTER_CONVERTER_METHODDEF \ |
127 | {"register_converter", (PyCFunction)(void(*)(void))pysqlite_register_converter, METH_FASTCALL, pysqlite_register_converter__doc__}, |
128 | |
129 | static PyObject * |
130 | pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name, |
131 | PyObject *callable); |
132 | |
133 | static PyObject * |
134 | pysqlite_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 | |
154 | exit: |
155 | return return_value; |
156 | } |
157 | |
158 | PyDoc_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 | |
167 | static PyObject * |
168 | pysqlite_enable_callback_trace_impl(PyObject *module, int enable); |
169 | |
170 | static PyObject * |
171 | pysqlite_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 | |
182 | exit: |
183 | return return_value; |
184 | } |
185 | |
186 | PyDoc_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)(void(*)(void))pysqlite_adapt, METH_FASTCALL, pysqlite_adapt__doc__}, |
194 | |
195 | static PyObject * |
196 | pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto, |
197 | PyObject *alt); |
198 | |
199 | static PyObject * |
200 | pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
201 | { |
202 | PyObject *return_value = NULL; |
203 | PyObject *obj; |
204 | PyObject *proto = (PyObject*)pysqlite_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]; |
219 | skip_optional: |
220 | return_value = pysqlite_adapt_impl(module, obj, proto, alt); |
221 | |
222 | exit: |
223 | return return_value; |
224 | } |
225 | /*[clinic end generated code: output=6939849a4371122d input=a9049054013a1b77]*/ |
226 | |