1 | /*[clinic input] |
2 | preserve |
3 | [clinic start generated code]*/ |
4 | |
5 | static int |
6 | pysqlite_cursor_init_impl(pysqlite_Cursor *self, |
7 | pysqlite_Connection *connection); |
8 | |
9 | static int |
10 | pysqlite_cursor_init(PyObject *self, PyObject *args, PyObject *kwargs) |
11 | { |
12 | int return_value = -1; |
13 | pysqlite_Connection *connection; |
14 | |
15 | if (Py_IS_TYPE(self, pysqlite_CursorType) && |
16 | !_PyArg_NoKeywords("Cursor" , kwargs)) { |
17 | goto exit; |
18 | } |
19 | if (!_PyArg_CheckPositional("Cursor" , PyTuple_GET_SIZE(args), 1, 1)) { |
20 | goto exit; |
21 | } |
22 | if (!PyObject_TypeCheck(PyTuple_GET_ITEM(args, 0), pysqlite_ConnectionType)) { |
23 | _PyArg_BadArgument("Cursor" , "argument 1" , (pysqlite_ConnectionType)->tp_name, PyTuple_GET_ITEM(args, 0)); |
24 | goto exit; |
25 | } |
26 | connection = (pysqlite_Connection *)PyTuple_GET_ITEM(args, 0); |
27 | return_value = pysqlite_cursor_init_impl((pysqlite_Cursor *)self, connection); |
28 | |
29 | exit: |
30 | return return_value; |
31 | } |
32 | |
33 | PyDoc_STRVAR(pysqlite_cursor_execute__doc__, |
34 | "execute($self, sql, parameters=(), /)\n" |
35 | "--\n" |
36 | "\n" |
37 | "Executes an SQL statement." ); |
38 | |
39 | #define PYSQLITE_CURSOR_EXECUTE_METHODDEF \ |
40 | {"execute", (PyCFunction)(void(*)(void))pysqlite_cursor_execute, METH_FASTCALL, pysqlite_cursor_execute__doc__}, |
41 | |
42 | static PyObject * |
43 | pysqlite_cursor_execute_impl(pysqlite_Cursor *self, PyObject *sql, |
44 | PyObject *parameters); |
45 | |
46 | static PyObject * |
47 | pysqlite_cursor_execute(pysqlite_Cursor *self, PyObject *const *args, Py_ssize_t nargs) |
48 | { |
49 | PyObject *return_value = NULL; |
50 | PyObject *sql; |
51 | PyObject *parameters = NULL; |
52 | |
53 | if (!_PyArg_CheckPositional("execute" , nargs, 1, 2)) { |
54 | goto exit; |
55 | } |
56 | if (!PyUnicode_Check(args[0])) { |
57 | _PyArg_BadArgument("execute" , "argument 1" , "str" , args[0]); |
58 | goto exit; |
59 | } |
60 | if (PyUnicode_READY(args[0]) == -1) { |
61 | goto exit; |
62 | } |
63 | sql = args[0]; |
64 | if (nargs < 2) { |
65 | goto skip_optional; |
66 | } |
67 | parameters = args[1]; |
68 | skip_optional: |
69 | return_value = pysqlite_cursor_execute_impl(self, sql, parameters); |
70 | |
71 | exit: |
72 | return return_value; |
73 | } |
74 | |
75 | PyDoc_STRVAR(pysqlite_cursor_executemany__doc__, |
76 | "executemany($self, sql, seq_of_parameters, /)\n" |
77 | "--\n" |
78 | "\n" |
79 | "Repeatedly executes an SQL statement." ); |
80 | |
81 | #define PYSQLITE_CURSOR_EXECUTEMANY_METHODDEF \ |
82 | {"executemany", (PyCFunction)(void(*)(void))pysqlite_cursor_executemany, METH_FASTCALL, pysqlite_cursor_executemany__doc__}, |
83 | |
84 | static PyObject * |
85 | pysqlite_cursor_executemany_impl(pysqlite_Cursor *self, PyObject *sql, |
86 | PyObject *seq_of_parameters); |
87 | |
88 | static PyObject * |
89 | pysqlite_cursor_executemany(pysqlite_Cursor *self, PyObject *const *args, Py_ssize_t nargs) |
90 | { |
91 | PyObject *return_value = NULL; |
92 | PyObject *sql; |
93 | PyObject *seq_of_parameters; |
94 | |
95 | if (!_PyArg_CheckPositional("executemany" , nargs, 2, 2)) { |
96 | goto exit; |
97 | } |
98 | if (!PyUnicode_Check(args[0])) { |
99 | _PyArg_BadArgument("executemany" , "argument 1" , "str" , args[0]); |
100 | goto exit; |
101 | } |
102 | if (PyUnicode_READY(args[0]) == -1) { |
103 | goto exit; |
104 | } |
105 | sql = args[0]; |
106 | seq_of_parameters = args[1]; |
107 | return_value = pysqlite_cursor_executemany_impl(self, sql, seq_of_parameters); |
108 | |
109 | exit: |
110 | return return_value; |
111 | } |
112 | |
113 | PyDoc_STRVAR(pysqlite_cursor_executescript__doc__, |
114 | "executescript($self, sql_script, /)\n" |
115 | "--\n" |
116 | "\n" |
117 | "Executes multiple SQL statements at once." ); |
118 | |
119 | #define PYSQLITE_CURSOR_EXECUTESCRIPT_METHODDEF \ |
120 | {"executescript", (PyCFunction)pysqlite_cursor_executescript, METH_O, pysqlite_cursor_executescript__doc__}, |
121 | |
122 | PyDoc_STRVAR(pysqlite_cursor_fetchone__doc__, |
123 | "fetchone($self, /)\n" |
124 | "--\n" |
125 | "\n" |
126 | "Fetches one row from the resultset." ); |
127 | |
128 | #define PYSQLITE_CURSOR_FETCHONE_METHODDEF \ |
129 | {"fetchone", (PyCFunction)pysqlite_cursor_fetchone, METH_NOARGS, pysqlite_cursor_fetchone__doc__}, |
130 | |
131 | static PyObject * |
132 | pysqlite_cursor_fetchone_impl(pysqlite_Cursor *self); |
133 | |
134 | static PyObject * |
135 | pysqlite_cursor_fetchone(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored)) |
136 | { |
137 | return pysqlite_cursor_fetchone_impl(self); |
138 | } |
139 | |
140 | PyDoc_STRVAR(pysqlite_cursor_fetchmany__doc__, |
141 | "fetchmany($self, /, size=1)\n" |
142 | "--\n" |
143 | "\n" |
144 | "Fetches several rows from the resultset.\n" |
145 | "\n" |
146 | " size\n" |
147 | " The default value is set by the Cursor.arraysize attribute." ); |
148 | |
149 | #define PYSQLITE_CURSOR_FETCHMANY_METHODDEF \ |
150 | {"fetchmany", (PyCFunction)(void(*)(void))pysqlite_cursor_fetchmany, METH_FASTCALL|METH_KEYWORDS, pysqlite_cursor_fetchmany__doc__}, |
151 | |
152 | static PyObject * |
153 | pysqlite_cursor_fetchmany_impl(pysqlite_Cursor *self, int maxrows); |
154 | |
155 | static PyObject * |
156 | pysqlite_cursor_fetchmany(pysqlite_Cursor *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
157 | { |
158 | PyObject *return_value = NULL; |
159 | static const char * const _keywords[] = {"size" , NULL}; |
160 | static _PyArg_Parser _parser = {NULL, _keywords, "fetchmany" , 0}; |
161 | PyObject *argsbuf[1]; |
162 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
163 | int maxrows = self->arraysize; |
164 | |
165 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
166 | if (!args) { |
167 | goto exit; |
168 | } |
169 | if (!noptargs) { |
170 | goto skip_optional_pos; |
171 | } |
172 | maxrows = _PyLong_AsInt(args[0]); |
173 | if (maxrows == -1 && PyErr_Occurred()) { |
174 | goto exit; |
175 | } |
176 | skip_optional_pos: |
177 | return_value = pysqlite_cursor_fetchmany_impl(self, maxrows); |
178 | |
179 | exit: |
180 | return return_value; |
181 | } |
182 | |
183 | PyDoc_STRVAR(pysqlite_cursor_fetchall__doc__, |
184 | "fetchall($self, /)\n" |
185 | "--\n" |
186 | "\n" |
187 | "Fetches all rows from the resultset." ); |
188 | |
189 | #define PYSQLITE_CURSOR_FETCHALL_METHODDEF \ |
190 | {"fetchall", (PyCFunction)pysqlite_cursor_fetchall, METH_NOARGS, pysqlite_cursor_fetchall__doc__}, |
191 | |
192 | static PyObject * |
193 | pysqlite_cursor_fetchall_impl(pysqlite_Cursor *self); |
194 | |
195 | static PyObject * |
196 | pysqlite_cursor_fetchall(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored)) |
197 | { |
198 | return pysqlite_cursor_fetchall_impl(self); |
199 | } |
200 | |
201 | PyDoc_STRVAR(pysqlite_cursor_setinputsizes__doc__, |
202 | "setinputsizes($self, sizes, /)\n" |
203 | "--\n" |
204 | "\n" |
205 | "Required by DB-API. Does nothing in sqlite3." ); |
206 | |
207 | #define PYSQLITE_CURSOR_SETINPUTSIZES_METHODDEF \ |
208 | {"setinputsizes", (PyCFunction)pysqlite_cursor_setinputsizes, METH_O, pysqlite_cursor_setinputsizes__doc__}, |
209 | |
210 | PyDoc_STRVAR(pysqlite_cursor_setoutputsize__doc__, |
211 | "setoutputsize($self, size, column=None, /)\n" |
212 | "--\n" |
213 | "\n" |
214 | "Required by DB-API. Does nothing in sqlite3." ); |
215 | |
216 | #define PYSQLITE_CURSOR_SETOUTPUTSIZE_METHODDEF \ |
217 | {"setoutputsize", (PyCFunction)(void(*)(void))pysqlite_cursor_setoutputsize, METH_FASTCALL, pysqlite_cursor_setoutputsize__doc__}, |
218 | |
219 | static PyObject * |
220 | pysqlite_cursor_setoutputsize_impl(pysqlite_Cursor *self, PyObject *size, |
221 | PyObject *column); |
222 | |
223 | static PyObject * |
224 | pysqlite_cursor_setoutputsize(pysqlite_Cursor *self, PyObject *const *args, Py_ssize_t nargs) |
225 | { |
226 | PyObject *return_value = NULL; |
227 | PyObject *size; |
228 | PyObject *column = Py_None; |
229 | |
230 | if (!_PyArg_CheckPositional("setoutputsize" , nargs, 1, 2)) { |
231 | goto exit; |
232 | } |
233 | size = args[0]; |
234 | if (nargs < 2) { |
235 | goto skip_optional; |
236 | } |
237 | column = args[1]; |
238 | skip_optional: |
239 | return_value = pysqlite_cursor_setoutputsize_impl(self, size, column); |
240 | |
241 | exit: |
242 | return return_value; |
243 | } |
244 | |
245 | PyDoc_STRVAR(pysqlite_cursor_close__doc__, |
246 | "close($self, /)\n" |
247 | "--\n" |
248 | "\n" |
249 | "Closes the cursor." ); |
250 | |
251 | #define PYSQLITE_CURSOR_CLOSE_METHODDEF \ |
252 | {"close", (PyCFunction)pysqlite_cursor_close, METH_NOARGS, pysqlite_cursor_close__doc__}, |
253 | |
254 | static PyObject * |
255 | pysqlite_cursor_close_impl(pysqlite_Cursor *self); |
256 | |
257 | static PyObject * |
258 | pysqlite_cursor_close(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored)) |
259 | { |
260 | return pysqlite_cursor_close_impl(self); |
261 | } |
262 | /*[clinic end generated code: output=9879e3a5d4ee3847 input=a9049054013a1b77]*/ |
263 | |