3 [clinic start generated code]*/
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
9 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
12 pysqlite_connection_init_impl(pysqlite_Connection
*self
, PyObject
*database
,
13 double timeout
, int detect_types
,
14 const char *isolation_level
,
15 int check_same_thread
, PyObject
*factory
,
16 int cache_size
, int uri
,
17 enum autocommit_mode autocommit
);
19 // Emit compiler warnings when we get to Python 3.15.
20 #if PY_VERSION_HEX >= 0x030f00C0
21 # error "Update the clinic input of '_sqlite3.Connection.__init__'."
22 #elif PY_VERSION_HEX >= 0x030f00A0
24 # pragma message ("Update the clinic input of '_sqlite3.Connection.__init__'.")
26 # warning "Update the clinic input of '_sqlite3.Connection.__init__'."
31 pysqlite_connection_init(PyObject
*self
, PyObject
*args
, PyObject
*kwargs
)
33 int return_value
= -1;
34 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
36 #define NUM_KEYWORDS 9
38 PyGC_Head _this_is_not_used
;
40 PyObject
*ob_item
[NUM_KEYWORDS
];
42 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
43 .ob_item
= { &_Py_ID(database
), &_Py_ID(timeout
), &_Py_ID(detect_types
), &_Py_ID(isolation_level
), &_Py_ID(check_same_thread
), &_Py_ID(factory
), &_Py_ID(cached_statements
), &_Py_ID(uri
), &_Py_ID(autocommit
), },
46 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
48 #else // !Py_BUILD_CORE
50 #endif // !Py_BUILD_CORE
52 static const char * const _keywords
[] = {"database", "timeout", "detect_types", "isolation_level", "check_same_thread", "factory", "cached_statements", "uri", "autocommit", NULL
};
53 static _PyArg_Parser _parser
= {
54 .keywords
= _keywords
,
55 .fname
= "Connection",
60 PyObject
* const *fastargs
;
61 Py_ssize_t nargs
= PyTuple_GET_SIZE(args
);
62 Py_ssize_t noptargs
= nargs
+ (kwargs
? PyDict_GET_SIZE(kwargs
) : 0) - 1;
66 const char *isolation_level
= "";
67 int check_same_thread
= 1;
68 PyObject
*factory
= (PyObject
*)clinic_state()->ConnectionType
;
71 enum autocommit_mode autocommit
= LEGACY_TRANSACTION_CONTROL
;
73 if (nargs
> 1 && nargs
<= 8) {
74 if (PyErr_WarnEx(PyExc_DeprecationWarning
,
75 "Passing more than 1 positional argument to _sqlite3.Connection()"
76 " is deprecated. Parameters 'timeout', 'detect_types', "
77 "'isolation_level', 'check_same_thread', 'factory', "
78 "'cached_statements' and 'uri' will become keyword-only "
79 "parameters in Python 3.15.", 1))
84 fastargs
= _PyArg_UnpackKeywords(_PyTuple_CAST(args
)->ob_item
, nargs
, kwargs
, NULL
, &_parser
, 1, 8, 0, argsbuf
);
88 database
= fastargs
[0];
90 goto skip_optional_pos
;
93 if (PyFloat_CheckExact(fastargs
[1])) {
94 timeout
= PyFloat_AS_DOUBLE(fastargs
[1]);
98 timeout
= PyFloat_AsDouble(fastargs
[1]);
99 if (timeout
== -1.0 && PyErr_Occurred()) {
104 goto skip_optional_pos
;
108 detect_types
= PyLong_AsInt(fastargs
[2]);
109 if (detect_types
== -1 && PyErr_Occurred()) {
113 goto skip_optional_pos
;
117 if (!isolation_level_converter(fastargs
[3], &isolation_level
)) {
121 goto skip_optional_pos
;
125 check_same_thread
= PyObject_IsTrue(fastargs
[4]);
126 if (check_same_thread
< 0) {
130 goto skip_optional_pos
;
134 factory
= fastargs
[5];
136 goto skip_optional_pos
;
140 cache_size
= PyLong_AsInt(fastargs
[6]);
141 if (cache_size
== -1 && PyErr_Occurred()) {
145 goto skip_optional_pos
;
149 uri
= PyObject_IsTrue(fastargs
[7]);
154 goto skip_optional_pos
;
159 goto skip_optional_kwonly
;
161 if (!autocommit_converter(fastargs
[8], &autocommit
)) {
164 skip_optional_kwonly
:
165 return_value
= pysqlite_connection_init_impl((pysqlite_Connection
*)self
, database
, timeout
, detect_types
, isolation_level
, check_same_thread
, factory
, cache_size
, uri
, autocommit
);
171 PyDoc_STRVAR(pysqlite_connection_cursor__doc__
,
172 "cursor($self, /, factory=<unrepresentable>)\n"
175 "Return a cursor for the connection.");
177 #define PYSQLITE_CONNECTION_CURSOR_METHODDEF \
178 {"cursor", _PyCFunction_CAST(pysqlite_connection_cursor), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__},
181 pysqlite_connection_cursor_impl(pysqlite_Connection
*self
, PyObject
*factory
);
184 pysqlite_connection_cursor(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
186 PyObject
*return_value
= NULL
;
187 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
189 #define NUM_KEYWORDS 1
191 PyGC_Head _this_is_not_used
;
193 PyObject
*ob_item
[NUM_KEYWORDS
];
195 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
196 .ob_item
= { &_Py_ID(factory
), },
199 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
201 #else // !Py_BUILD_CORE
202 # define KWTUPLE NULL
203 #endif // !Py_BUILD_CORE
205 static const char * const _keywords
[] = {"factory", NULL
};
206 static _PyArg_Parser _parser
= {
207 .keywords
= _keywords
,
212 PyObject
*argsbuf
[1];
213 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 0;
214 PyObject
*factory
= NULL
;
216 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 0, 1, 0, argsbuf
);
221 goto skip_optional_pos
;
225 return_value
= pysqlite_connection_cursor_impl(self
, factory
);
231 PyDoc_STRVAR(blobopen__doc__
,
232 "blobopen($self, table, column, row, /, *, readonly=False, name=\'main\')\n"
235 "Open and return a BLOB object.\n"
244 " Open the BLOB without write permissions.\n"
248 #define BLOBOPEN_METHODDEF \
249 {"blobopen", _PyCFunction_CAST(blobopen), METH_FASTCALL|METH_KEYWORDS, blobopen__doc__},
252 blobopen_impl(pysqlite_Connection
*self
, const char *table
, const char *col
,
253 sqlite3_int64 row
, int readonly
, const char *name
);
256 blobopen(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
258 PyObject
*return_value
= NULL
;
259 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
261 #define NUM_KEYWORDS 2
263 PyGC_Head _this_is_not_used
;
265 PyObject
*ob_item
[NUM_KEYWORDS
];
267 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
268 .ob_item
= { &_Py_ID(readonly
), &_Py_ID(name
), },
271 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
273 #else // !Py_BUILD_CORE
274 # define KWTUPLE NULL
275 #endif // !Py_BUILD_CORE
277 static const char * const _keywords
[] = {"", "", "", "readonly", "name", NULL
};
278 static _PyArg_Parser _parser
= {
279 .keywords
= _keywords
,
284 PyObject
*argsbuf
[5];
285 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 3;
290 const char *name
= "main";
292 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 3, 3, 0, argsbuf
);
296 if (!PyUnicode_Check(args
[0])) {
297 _PyArg_BadArgument("blobopen", "argument 1", "str", args
[0]);
300 Py_ssize_t table_length
;
301 table
= PyUnicode_AsUTF8AndSize(args
[0], &table_length
);
305 if (strlen(table
) != (size_t)table_length
) {
306 PyErr_SetString(PyExc_ValueError
, "embedded null character");
309 if (!PyUnicode_Check(args
[1])) {
310 _PyArg_BadArgument("blobopen", "argument 2", "str", args
[1]);
313 Py_ssize_t col_length
;
314 col
= PyUnicode_AsUTF8AndSize(args
[1], &col_length
);
318 if (strlen(col
) != (size_t)col_length
) {
319 PyErr_SetString(PyExc_ValueError
, "embedded null character");
322 if (!sqlite3_int64_converter(args
[2], &row
)) {
326 goto skip_optional_kwonly
;
329 readonly
= PyObject_IsTrue(args
[3]);
334 goto skip_optional_kwonly
;
337 if (!PyUnicode_Check(args
[4])) {
338 _PyArg_BadArgument("blobopen", "argument 'name'", "str", args
[4]);
341 Py_ssize_t name_length
;
342 name
= PyUnicode_AsUTF8AndSize(args
[4], &name_length
);
346 if (strlen(name
) != (size_t)name_length
) {
347 PyErr_SetString(PyExc_ValueError
, "embedded null character");
350 skip_optional_kwonly
:
351 return_value
= blobopen_impl(self
, table
, col
, row
, readonly
, name
);
357 PyDoc_STRVAR(pysqlite_connection_close__doc__
,
361 "Close the database connection.\n"
363 "Any pending transaction is not committed implicitly.");
365 #define PYSQLITE_CONNECTION_CLOSE_METHODDEF \
366 {"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS, pysqlite_connection_close__doc__},
369 pysqlite_connection_close_impl(pysqlite_Connection
*self
);
372 pysqlite_connection_close(pysqlite_Connection
*self
, PyObject
*Py_UNUSED(ignored
))
374 return pysqlite_connection_close_impl(self
);
377 PyDoc_STRVAR(pysqlite_connection_commit__doc__
,
381 "Commit any pending transaction to the database.\n"
383 "If there is no open transaction, this method is a no-op.");
385 #define PYSQLITE_CONNECTION_COMMIT_METHODDEF \
386 {"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS, pysqlite_connection_commit__doc__},
389 pysqlite_connection_commit_impl(pysqlite_Connection
*self
);
392 pysqlite_connection_commit(pysqlite_Connection
*self
, PyObject
*Py_UNUSED(ignored
))
394 return pysqlite_connection_commit_impl(self
);
397 PyDoc_STRVAR(pysqlite_connection_rollback__doc__
,
398 "rollback($self, /)\n"
401 "Roll back to the start of any pending transaction.\n"
403 "If there is no open transaction, this method is a no-op.");
405 #define PYSQLITE_CONNECTION_ROLLBACK_METHODDEF \
406 {"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS, pysqlite_connection_rollback__doc__},
409 pysqlite_connection_rollback_impl(pysqlite_Connection
*self
);
412 pysqlite_connection_rollback(pysqlite_Connection
*self
, PyObject
*Py_UNUSED(ignored
))
414 return pysqlite_connection_rollback_impl(self
);
417 PyDoc_STRVAR(pysqlite_connection_create_function__doc__
,
418 "create_function($self, /, name, narg, func, *, deterministic=False)\n"
421 "Creates a new function.\n"
423 "Note: Passing keyword arguments \'name\', \'narg\' and \'func\' to\n"
424 "_sqlite3.Connection.create_function() is deprecated. Parameters\n"
425 "\'name\', \'narg\' and \'func\' will become positional-only in Python 3.15.\n"
428 #define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF \
429 {"create_function", _PyCFunction_CAST(pysqlite_connection_create_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__},
432 pysqlite_connection_create_function_impl(pysqlite_Connection
*self
,
433 PyTypeObject
*cls
, const char *name
,
434 int narg
, PyObject
*func
,
437 // Emit compiler warnings when we get to Python 3.15.
438 #if PY_VERSION_HEX >= 0x030f00C0
439 # error "Update the clinic input of '_sqlite3.Connection.create_function'."
440 #elif PY_VERSION_HEX >= 0x030f00A0
442 # pragma message ("Update the clinic input of '_sqlite3.Connection.create_function'.")
444 # warning "Update the clinic input of '_sqlite3.Connection.create_function'."
449 pysqlite_connection_create_function(pysqlite_Connection
*self
, PyTypeObject
*cls
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
451 PyObject
*return_value
= NULL
;
452 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
454 #define NUM_KEYWORDS 4
456 PyGC_Head _this_is_not_used
;
458 PyObject
*ob_item
[NUM_KEYWORDS
];
460 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
461 .ob_item
= { &_Py_ID(name
), &_Py_ID(narg
), &_Py_ID(func
), &_Py_ID(deterministic
), },
464 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
466 #else // !Py_BUILD_CORE
467 # define KWTUPLE NULL
468 #endif // !Py_BUILD_CORE
470 static const char * const _keywords
[] = {"name", "narg", "func", "deterministic", NULL
};
471 static _PyArg_Parser _parser
= {
472 .keywords
= _keywords
,
473 .fname
= "create_function",
477 PyObject
*argsbuf
[4];
478 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 3;
482 int deterministic
= 0;
484 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 3, 3, 0, argsbuf
);
489 if (PyErr_WarnEx(PyExc_DeprecationWarning
,
490 "Passing keyword arguments 'name', 'narg' and 'func' to "
491 "_sqlite3.Connection.create_function() is deprecated. Parameters "
492 "'name', 'narg' and 'func' will become positional-only in Python "
498 if (!PyUnicode_Check(args
[0])) {
499 _PyArg_BadArgument("create_function", "argument 'name'", "str", args
[0]);
502 Py_ssize_t name_length
;
503 name
= PyUnicode_AsUTF8AndSize(args
[0], &name_length
);
507 if (strlen(name
) != (size_t)name_length
) {
508 PyErr_SetString(PyExc_ValueError
, "embedded null character");
511 narg
= PyLong_AsInt(args
[1]);
512 if (narg
== -1 && PyErr_Occurred()) {
517 goto skip_optional_kwonly
;
519 deterministic
= PyObject_IsTrue(args
[3]);
520 if (deterministic
< 0) {
523 skip_optional_kwonly
:
524 return_value
= pysqlite_connection_create_function_impl(self
, cls
, name
, narg
, func
, deterministic
);
530 #if defined(HAVE_WINDOW_FUNCTIONS)
532 PyDoc_STRVAR(create_window_function__doc__
,
533 "create_window_function($self, name, num_params, aggregate_class, /)\n"
536 "Creates or redefines an aggregate window function. Non-standard.\n"
539 " The name of the SQL aggregate window function to be created or\n"
542 " The number of arguments the step and inverse methods takes.\n"
544 " A class with step(), finalize(), value(), and inverse() methods.\n"
545 " Set to None to clear the window function.");
547 #define CREATE_WINDOW_FUNCTION_METHODDEF \
548 {"create_window_function", _PyCFunction_CAST(create_window_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, create_window_function__doc__},
551 create_window_function_impl(pysqlite_Connection
*self
, PyTypeObject
*cls
,
552 const char *name
, int num_params
,
553 PyObject
*aggregate_class
);
556 create_window_function(pysqlite_Connection
*self
, PyTypeObject
*cls
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
558 PyObject
*return_value
= NULL
;
559 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
560 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
562 # define KWTUPLE NULL
565 static const char * const _keywords
[] = {"", "", "", NULL
};
566 static _PyArg_Parser _parser
= {
567 .keywords
= _keywords
,
568 .fname
= "create_window_function",
572 PyObject
*argsbuf
[3];
575 PyObject
*aggregate_class
;
577 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 3, 3, 0, argsbuf
);
581 if (!PyUnicode_Check(args
[0])) {
582 _PyArg_BadArgument("create_window_function", "argument 1", "str", args
[0]);
585 Py_ssize_t name_length
;
586 name
= PyUnicode_AsUTF8AndSize(args
[0], &name_length
);
590 if (strlen(name
) != (size_t)name_length
) {
591 PyErr_SetString(PyExc_ValueError
, "embedded null character");
594 num_params
= PyLong_AsInt(args
[1]);
595 if (num_params
== -1 && PyErr_Occurred()) {
598 aggregate_class
= args
[2];
599 return_value
= create_window_function_impl(self
, cls
, name
, num_params
, aggregate_class
);
605 #endif /* defined(HAVE_WINDOW_FUNCTIONS) */
607 PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__
,
608 "create_aggregate($self, /, name, n_arg, aggregate_class)\n"
611 "Creates a new aggregate.\n"
613 "Note: Passing keyword arguments \'name\', \'n_arg\' and \'aggregate_class\'\n"
614 "to _sqlite3.Connection.create_aggregate() is deprecated. Parameters\n"
615 "\'name\', \'n_arg\' and \'aggregate_class\' will become positional-only in\n"
619 #define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF \
620 {"create_aggregate", _PyCFunction_CAST(pysqlite_connection_create_aggregate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__},
623 pysqlite_connection_create_aggregate_impl(pysqlite_Connection
*self
,
625 const char *name
, int n_arg
,
626 PyObject
*aggregate_class
);
628 // Emit compiler warnings when we get to Python 3.15.
629 #if PY_VERSION_HEX >= 0x030f00C0
630 # error "Update the clinic input of '_sqlite3.Connection.create_aggregate'."
631 #elif PY_VERSION_HEX >= 0x030f00A0
633 # pragma message ("Update the clinic input of '_sqlite3.Connection.create_aggregate'.")
635 # warning "Update the clinic input of '_sqlite3.Connection.create_aggregate'."
640 pysqlite_connection_create_aggregate(pysqlite_Connection
*self
, PyTypeObject
*cls
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
642 PyObject
*return_value
= NULL
;
643 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
645 #define NUM_KEYWORDS 3
647 PyGC_Head _this_is_not_used
;
649 PyObject
*ob_item
[NUM_KEYWORDS
];
651 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
652 .ob_item
= { &_Py_ID(name
), &_Py_ID(n_arg
), &_Py_ID(aggregate_class
), },
655 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
657 #else // !Py_BUILD_CORE
658 # define KWTUPLE NULL
659 #endif // !Py_BUILD_CORE
661 static const char * const _keywords
[] = {"name", "n_arg", "aggregate_class", NULL
};
662 static _PyArg_Parser _parser
= {
663 .keywords
= _keywords
,
664 .fname
= "create_aggregate",
668 PyObject
*argsbuf
[3];
671 PyObject
*aggregate_class
;
673 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 3, 3, 0, argsbuf
);
678 if (PyErr_WarnEx(PyExc_DeprecationWarning
,
679 "Passing keyword arguments 'name', 'n_arg' and 'aggregate_class' "
680 "to _sqlite3.Connection.create_aggregate() is deprecated. "
681 "Parameters 'name', 'n_arg' and 'aggregate_class' will become "
682 "positional-only in Python 3.15.", 1))
687 if (!PyUnicode_Check(args
[0])) {
688 _PyArg_BadArgument("create_aggregate", "argument 'name'", "str", args
[0]);
691 Py_ssize_t name_length
;
692 name
= PyUnicode_AsUTF8AndSize(args
[0], &name_length
);
696 if (strlen(name
) != (size_t)name_length
) {
697 PyErr_SetString(PyExc_ValueError
, "embedded null character");
700 n_arg
= PyLong_AsInt(args
[1]);
701 if (n_arg
== -1 && PyErr_Occurred()) {
704 aggregate_class
= args
[2];
705 return_value
= pysqlite_connection_create_aggregate_impl(self
, cls
, name
, n_arg
, aggregate_class
);
711 PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__
,
712 "set_authorizer($self, /, authorizer_callback)\n"
715 "Set authorizer callback.\n"
717 "Note: Passing keyword argument \'authorizer_callback\' to\n"
718 "_sqlite3.Connection.set_authorizer() is deprecated. Parameter\n"
719 "\'authorizer_callback\' will become positional-only in Python 3.15.\n"
722 #define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF \
723 {"set_authorizer", _PyCFunction_CAST(pysqlite_connection_set_authorizer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},
726 pysqlite_connection_set_authorizer_impl(pysqlite_Connection
*self
,
730 // Emit compiler warnings when we get to Python 3.15.
731 #if PY_VERSION_HEX >= 0x030f00C0
732 # error "Update the clinic input of '_sqlite3.Connection.set_authorizer'."
733 #elif PY_VERSION_HEX >= 0x030f00A0
735 # pragma message ("Update the clinic input of '_sqlite3.Connection.set_authorizer'.")
737 # warning "Update the clinic input of '_sqlite3.Connection.set_authorizer'."
742 pysqlite_connection_set_authorizer(pysqlite_Connection
*self
, PyTypeObject
*cls
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
744 PyObject
*return_value
= NULL
;
745 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
747 #define NUM_KEYWORDS 1
749 PyGC_Head _this_is_not_used
;
751 PyObject
*ob_item
[NUM_KEYWORDS
];
753 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
754 .ob_item
= { &_Py_ID(authorizer_callback
), },
757 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
759 #else // !Py_BUILD_CORE
760 # define KWTUPLE NULL
761 #endif // !Py_BUILD_CORE
763 static const char * const _keywords
[] = {"authorizer_callback", NULL
};
764 static _PyArg_Parser _parser
= {
765 .keywords
= _keywords
,
766 .fname
= "set_authorizer",
770 PyObject
*argsbuf
[1];
773 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 1, 1, 0, argsbuf
);
778 if (PyErr_WarnEx(PyExc_DeprecationWarning
,
779 "Passing keyword argument 'authorizer_callback' to "
780 "_sqlite3.Connection.set_authorizer() is deprecated. Parameter "
781 "'authorizer_callback' will become positional-only in Python "
788 return_value
= pysqlite_connection_set_authorizer_impl(self
, cls
, callable
);
794 PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__
,
795 "set_progress_handler($self, /, progress_handler, n)\n"
798 "Set progress handler callback.\n"
800 " progress_handler\n"
801 " A callable that takes no arguments.\n"
802 " If the callable returns non-zero, the current query is terminated,\n"
803 " and an exception is raised.\n"
805 " The number of SQLite virtual machine instructions that are\n"
806 " executed between invocations of \'progress_handler\'.\n"
808 "If \'progress_handler\' is None or \'n\' is 0, the progress handler is disabled.\n"
810 "Note: Passing keyword argument \'progress_handler\' to\n"
811 "_sqlite3.Connection.set_progress_handler() is deprecated. Parameter\n"
812 "\'progress_handler\' will become positional-only in Python 3.15.\n"
815 #define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF \
816 {"set_progress_handler", _PyCFunction_CAST(pysqlite_connection_set_progress_handler), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__},
819 pysqlite_connection_set_progress_handler_impl(pysqlite_Connection
*self
,
821 PyObject
*callable
, int n
);
823 // Emit compiler warnings when we get to Python 3.15.
824 #if PY_VERSION_HEX >= 0x030f00C0
825 # error "Update the clinic input of '_sqlite3.Connection.set_progress_handler'."
826 #elif PY_VERSION_HEX >= 0x030f00A0
828 # pragma message ("Update the clinic input of '_sqlite3.Connection.set_progress_handler'.")
830 # warning "Update the clinic input of '_sqlite3.Connection.set_progress_handler'."
835 pysqlite_connection_set_progress_handler(pysqlite_Connection
*self
, PyTypeObject
*cls
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
837 PyObject
*return_value
= NULL
;
838 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
840 #define NUM_KEYWORDS 2
842 PyGC_Head _this_is_not_used
;
844 PyObject
*ob_item
[NUM_KEYWORDS
];
846 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
847 .ob_item
= { &_Py_ID(progress_handler
), &_Py_ID(n
), },
850 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
852 #else // !Py_BUILD_CORE
853 # define KWTUPLE NULL
854 #endif // !Py_BUILD_CORE
856 static const char * const _keywords
[] = {"progress_handler", "n", NULL
};
857 static _PyArg_Parser _parser
= {
858 .keywords
= _keywords
,
859 .fname
= "set_progress_handler",
863 PyObject
*argsbuf
[2];
867 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 2, 2, 0, argsbuf
);
872 if (PyErr_WarnEx(PyExc_DeprecationWarning
,
873 "Passing keyword argument 'progress_handler' to "
874 "_sqlite3.Connection.set_progress_handler() is deprecated. "
875 "Parameter 'progress_handler' will become positional-only in "
882 n
= PyLong_AsInt(args
[1]);
883 if (n
== -1 && PyErr_Occurred()) {
886 return_value
= pysqlite_connection_set_progress_handler_impl(self
, cls
, callable
, n
);
892 PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__
,
893 "set_trace_callback($self, /, trace_callback)\n"
896 "Set a trace callback called for each SQL statement (passed as unicode).\n"
898 "Note: Passing keyword argument \'trace_callback\' to\n"
899 "_sqlite3.Connection.set_trace_callback() is deprecated. Parameter\n"
900 "\'trace_callback\' will become positional-only in Python 3.15.\n"
903 #define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF \
904 {"set_trace_callback", _PyCFunction_CAST(pysqlite_connection_set_trace_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__},
907 pysqlite_connection_set_trace_callback_impl(pysqlite_Connection
*self
,
911 // Emit compiler warnings when we get to Python 3.15.
912 #if PY_VERSION_HEX >= 0x030f00C0
913 # error "Update the clinic input of '_sqlite3.Connection.set_trace_callback'."
914 #elif PY_VERSION_HEX >= 0x030f00A0
916 # pragma message ("Update the clinic input of '_sqlite3.Connection.set_trace_callback'.")
918 # warning "Update the clinic input of '_sqlite3.Connection.set_trace_callback'."
923 pysqlite_connection_set_trace_callback(pysqlite_Connection
*self
, PyTypeObject
*cls
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
925 PyObject
*return_value
= NULL
;
926 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
928 #define NUM_KEYWORDS 1
930 PyGC_Head _this_is_not_used
;
932 PyObject
*ob_item
[NUM_KEYWORDS
];
934 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
935 .ob_item
= { &_Py_ID(trace_callback
), },
938 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
940 #else // !Py_BUILD_CORE
941 # define KWTUPLE NULL
942 #endif // !Py_BUILD_CORE
944 static const char * const _keywords
[] = {"trace_callback", NULL
};
945 static _PyArg_Parser _parser
= {
946 .keywords
= _keywords
,
947 .fname
= "set_trace_callback",
951 PyObject
*argsbuf
[1];
954 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 1, 1, 0, argsbuf
);
959 if (PyErr_WarnEx(PyExc_DeprecationWarning
,
960 "Passing keyword argument 'trace_callback' to "
961 "_sqlite3.Connection.set_trace_callback() is deprecated. "
962 "Parameter 'trace_callback' will become positional-only in Python"
969 return_value
= pysqlite_connection_set_trace_callback_impl(self
, cls
, callable
);
975 #if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
977 PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__
,
978 "enable_load_extension($self, enable, /)\n"
981 "Enable dynamic loading of SQLite extension modules.");
983 #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF \
984 {"enable_load_extension", (PyCFunction)pysqlite_connection_enable_load_extension, METH_O, pysqlite_connection_enable_load_extension__doc__},
987 pysqlite_connection_enable_load_extension_impl(pysqlite_Connection
*self
,
991 pysqlite_connection_enable_load_extension(pysqlite_Connection
*self
, PyObject
*arg
)
993 PyObject
*return_value
= NULL
;
996 onoff
= PyObject_IsTrue(arg
);
1000 return_value
= pysqlite_connection_enable_load_extension_impl(self
, onoff
);
1003 return return_value
;
1006 #endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
1008 #if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
1010 PyDoc_STRVAR(pysqlite_connection_load_extension__doc__
,
1011 "load_extension($self, name, /, *, entrypoint=None)\n"
1014 "Load SQLite extension module.");
1016 #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF \
1017 {"load_extension", _PyCFunction_CAST(pysqlite_connection_load_extension), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_load_extension__doc__},
1020 pysqlite_connection_load_extension_impl(pysqlite_Connection
*self
,
1021 const char *extension_name
,
1022 const char *entrypoint
);
1025 pysqlite_connection_load_extension(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
1027 PyObject
*return_value
= NULL
;
1028 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1030 #define NUM_KEYWORDS 1
1032 PyGC_Head _this_is_not_used
;
1034 PyObject
*ob_item
[NUM_KEYWORDS
];
1036 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
1037 .ob_item
= { &_Py_ID(entrypoint
), },
1040 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1042 #else // !Py_BUILD_CORE
1043 # define KWTUPLE NULL
1044 #endif // !Py_BUILD_CORE
1046 static const char * const _keywords
[] = {"", "entrypoint", NULL
};
1047 static _PyArg_Parser _parser
= {
1048 .keywords
= _keywords
,
1049 .fname
= "load_extension",
1053 PyObject
*argsbuf
[2];
1054 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 1;
1055 const char *extension_name
;
1056 const char *entrypoint
= NULL
;
1058 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 1, 1, 0, argsbuf
);
1062 if (!PyUnicode_Check(args
[0])) {
1063 _PyArg_BadArgument("load_extension", "argument 1", "str", args
[0]);
1066 Py_ssize_t extension_name_length
;
1067 extension_name
= PyUnicode_AsUTF8AndSize(args
[0], &extension_name_length
);
1068 if (extension_name
== NULL
) {
1071 if (strlen(extension_name
) != (size_t)extension_name_length
) {
1072 PyErr_SetString(PyExc_ValueError
, "embedded null character");
1076 goto skip_optional_kwonly
;
1078 if (args
[1] == Py_None
) {
1081 else if (PyUnicode_Check(args
[1])) {
1082 Py_ssize_t entrypoint_length
;
1083 entrypoint
= PyUnicode_AsUTF8AndSize(args
[1], &entrypoint_length
);
1084 if (entrypoint
== NULL
) {
1087 if (strlen(entrypoint
) != (size_t)entrypoint_length
) {
1088 PyErr_SetString(PyExc_ValueError
, "embedded null character");
1093 _PyArg_BadArgument("load_extension", "argument 'entrypoint'", "str or None", args
[1]);
1096 skip_optional_kwonly
:
1097 return_value
= pysqlite_connection_load_extension_impl(self
, extension_name
, entrypoint
);
1100 return return_value
;
1103 #endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
1105 PyDoc_STRVAR(pysqlite_connection_execute__doc__
,
1106 "execute($self, sql, parameters=<unrepresentable>, /)\n"
1109 "Executes an SQL statement.");
1111 #define PYSQLITE_CONNECTION_EXECUTE_METHODDEF \
1112 {"execute", _PyCFunction_CAST(pysqlite_connection_execute), METH_FASTCALL, pysqlite_connection_execute__doc__},
1115 pysqlite_connection_execute_impl(pysqlite_Connection
*self
, PyObject
*sql
,
1116 PyObject
*parameters
);
1119 pysqlite_connection_execute(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
)
1121 PyObject
*return_value
= NULL
;
1123 PyObject
*parameters
= NULL
;
1125 if (!_PyArg_CheckPositional("execute", nargs
, 1, 2)) {
1128 if (!PyUnicode_Check(args
[0])) {
1129 _PyArg_BadArgument("execute", "argument 1", "str", args
[0]);
1136 parameters
= args
[1];
1138 return_value
= pysqlite_connection_execute_impl(self
, sql
, parameters
);
1141 return return_value
;
1144 PyDoc_STRVAR(pysqlite_connection_executemany__doc__
,
1145 "executemany($self, sql, parameters, /)\n"
1148 "Repeatedly executes an SQL statement.");
1150 #define PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF \
1151 {"executemany", _PyCFunction_CAST(pysqlite_connection_executemany), METH_FASTCALL, pysqlite_connection_executemany__doc__},
1154 pysqlite_connection_executemany_impl(pysqlite_Connection
*self
,
1155 PyObject
*sql
, PyObject
*parameters
);
1158 pysqlite_connection_executemany(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
)
1160 PyObject
*return_value
= NULL
;
1162 PyObject
*parameters
;
1164 if (!_PyArg_CheckPositional("executemany", nargs
, 2, 2)) {
1167 if (!PyUnicode_Check(args
[0])) {
1168 _PyArg_BadArgument("executemany", "argument 1", "str", args
[0]);
1172 parameters
= args
[1];
1173 return_value
= pysqlite_connection_executemany_impl(self
, sql
, parameters
);
1176 return return_value
;
1179 PyDoc_STRVAR(pysqlite_connection_executescript__doc__
,
1180 "executescript($self, sql_script, /)\n"
1183 "Executes multiple SQL statements at once.");
1185 #define PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF \
1186 {"executescript", (PyCFunction)pysqlite_connection_executescript, METH_O, pysqlite_connection_executescript__doc__},
1188 PyDoc_STRVAR(pysqlite_connection_interrupt__doc__
,
1189 "interrupt($self, /)\n"
1192 "Abort any pending database operation.");
1194 #define PYSQLITE_CONNECTION_INTERRUPT_METHODDEF \
1195 {"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS, pysqlite_connection_interrupt__doc__},
1198 pysqlite_connection_interrupt_impl(pysqlite_Connection
*self
);
1201 pysqlite_connection_interrupt(pysqlite_Connection
*self
, PyObject
*Py_UNUSED(ignored
))
1203 return pysqlite_connection_interrupt_impl(self
);
1206 PyDoc_STRVAR(pysqlite_connection_iterdump__doc__
,
1207 "iterdump($self, /, *, filter=None)\n"
1210 "Returns iterator to the dump of the database in an SQL text format.\n"
1213 " An optional LIKE pattern for database objects to dump");
1215 #define PYSQLITE_CONNECTION_ITERDUMP_METHODDEF \
1216 {"iterdump", _PyCFunction_CAST(pysqlite_connection_iterdump), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_iterdump__doc__},
1219 pysqlite_connection_iterdump_impl(pysqlite_Connection
*self
,
1223 pysqlite_connection_iterdump(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
1225 PyObject
*return_value
= NULL
;
1226 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1228 #define NUM_KEYWORDS 1
1230 PyGC_Head _this_is_not_used
;
1232 PyObject
*ob_item
[NUM_KEYWORDS
];
1234 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
1235 .ob_item
= { &_Py_ID(filter
), },
1238 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1240 #else // !Py_BUILD_CORE
1241 # define KWTUPLE NULL
1242 #endif // !Py_BUILD_CORE
1244 static const char * const _keywords
[] = {"filter", NULL
};
1245 static _PyArg_Parser _parser
= {
1246 .keywords
= _keywords
,
1247 .fname
= "iterdump",
1251 PyObject
*argsbuf
[1];
1252 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 0;
1253 PyObject
*filter
= Py_None
;
1255 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 0, 0, 0, argsbuf
);
1260 goto skip_optional_kwonly
;
1263 skip_optional_kwonly
:
1264 return_value
= pysqlite_connection_iterdump_impl(self
, filter
);
1267 return return_value
;
1270 PyDoc_STRVAR(pysqlite_connection_backup__doc__
,
1271 "backup($self, /, target, *, pages=-1, progress=None, name=\'main\',\n"
1275 "Makes a backup of the database.");
1277 #define PYSQLITE_CONNECTION_BACKUP_METHODDEF \
1278 {"backup", _PyCFunction_CAST(pysqlite_connection_backup), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__},
1281 pysqlite_connection_backup_impl(pysqlite_Connection
*self
,
1282 pysqlite_Connection
*target
, int pages
,
1283 PyObject
*progress
, const char *name
,
1287 pysqlite_connection_backup(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
1289 PyObject
*return_value
= NULL
;
1290 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1292 #define NUM_KEYWORDS 5
1294 PyGC_Head _this_is_not_used
;
1296 PyObject
*ob_item
[NUM_KEYWORDS
];
1298 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
1299 .ob_item
= { &_Py_ID(target
), &_Py_ID(pages
), &_Py_ID(progress
), &_Py_ID(name
), &_Py_ID(sleep
), },
1302 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1304 #else // !Py_BUILD_CORE
1305 # define KWTUPLE NULL
1306 #endif // !Py_BUILD_CORE
1308 static const char * const _keywords
[] = {"target", "pages", "progress", "name", "sleep", NULL
};
1309 static _PyArg_Parser _parser
= {
1310 .keywords
= _keywords
,
1315 PyObject
*argsbuf
[5];
1316 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 1;
1317 pysqlite_Connection
*target
;
1319 PyObject
*progress
= Py_None
;
1320 const char *name
= "main";
1321 double sleep
= 0.25;
1323 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 1, 1, 0, argsbuf
);
1327 if (!PyObject_TypeCheck(args
[0], clinic_state()->ConnectionType
)) {
1328 _PyArg_BadArgument("backup", "argument 'target'", (clinic_state()->ConnectionType
)->tp_name
, args
[0]);
1331 target
= (pysqlite_Connection
*)args
[0];
1333 goto skip_optional_kwonly
;
1336 pages
= PyLong_AsInt(args
[1]);
1337 if (pages
== -1 && PyErr_Occurred()) {
1341 goto skip_optional_kwonly
;
1347 goto skip_optional_kwonly
;
1351 if (!PyUnicode_Check(args
[3])) {
1352 _PyArg_BadArgument("backup", "argument 'name'", "str", args
[3]);
1355 Py_ssize_t name_length
;
1356 name
= PyUnicode_AsUTF8AndSize(args
[3], &name_length
);
1360 if (strlen(name
) != (size_t)name_length
) {
1361 PyErr_SetString(PyExc_ValueError
, "embedded null character");
1365 goto skip_optional_kwonly
;
1368 if (PyFloat_CheckExact(args
[4])) {
1369 sleep
= PyFloat_AS_DOUBLE(args
[4]);
1373 sleep
= PyFloat_AsDouble(args
[4]);
1374 if (sleep
== -1.0 && PyErr_Occurred()) {
1378 skip_optional_kwonly
:
1379 return_value
= pysqlite_connection_backup_impl(self
, target
, pages
, progress
, name
, sleep
);
1382 return return_value
;
1385 PyDoc_STRVAR(pysqlite_connection_create_collation__doc__
,
1386 "create_collation($self, name, callback, /)\n"
1389 "Creates a collation function.");
1391 #define PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF \
1392 {"create_collation", _PyCFunction_CAST(pysqlite_connection_create_collation), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_collation__doc__},
1395 pysqlite_connection_create_collation_impl(pysqlite_Connection
*self
,
1398 PyObject
*callable
);
1401 pysqlite_connection_create_collation(pysqlite_Connection
*self
, PyTypeObject
*cls
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
1403 PyObject
*return_value
= NULL
;
1404 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1405 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
1407 # define KWTUPLE NULL
1410 static const char * const _keywords
[] = {"", "", NULL
};
1411 static _PyArg_Parser _parser
= {
1412 .keywords
= _keywords
,
1413 .fname
= "create_collation",
1417 PyObject
*argsbuf
[2];
1421 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 2, 2, 0, argsbuf
);
1425 if (!PyUnicode_Check(args
[0])) {
1426 _PyArg_BadArgument("create_collation", "argument 1", "str", args
[0]);
1429 Py_ssize_t name_length
;
1430 name
= PyUnicode_AsUTF8AndSize(args
[0], &name_length
);
1434 if (strlen(name
) != (size_t)name_length
) {
1435 PyErr_SetString(PyExc_ValueError
, "embedded null character");
1439 return_value
= pysqlite_connection_create_collation_impl(self
, cls
, name
, callable
);
1442 return return_value
;
1445 #if defined(PY_SQLITE_HAVE_SERIALIZE)
1447 PyDoc_STRVAR(serialize__doc__
,
1448 "serialize($self, /, *, name=\'main\')\n"
1451 "Serialize a database into a byte string.\n"
1454 " Which database to serialize.\n"
1456 "For an ordinary on-disk database file, the serialization is just a copy of the\n"
1457 "disk file. For an in-memory database or a \"temp\" database, the serialization is\n"
1458 "the same sequence of bytes which would be written to disk if that database\n"
1459 "were backed up to disk.");
1461 #define SERIALIZE_METHODDEF \
1462 {"serialize", _PyCFunction_CAST(serialize), METH_FASTCALL|METH_KEYWORDS, serialize__doc__},
1465 serialize_impl(pysqlite_Connection
*self
, const char *name
);
1468 serialize(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
1470 PyObject
*return_value
= NULL
;
1471 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1473 #define NUM_KEYWORDS 1
1475 PyGC_Head _this_is_not_used
;
1477 PyObject
*ob_item
[NUM_KEYWORDS
];
1479 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
1480 .ob_item
= { &_Py_ID(name
), },
1483 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1485 #else // !Py_BUILD_CORE
1486 # define KWTUPLE NULL
1487 #endif // !Py_BUILD_CORE
1489 static const char * const _keywords
[] = {"name", NULL
};
1490 static _PyArg_Parser _parser
= {
1491 .keywords
= _keywords
,
1492 .fname
= "serialize",
1496 PyObject
*argsbuf
[1];
1497 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 0;
1498 const char *name
= "main";
1500 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 0, 0, 0, argsbuf
);
1505 goto skip_optional_kwonly
;
1507 if (!PyUnicode_Check(args
[0])) {
1508 _PyArg_BadArgument("serialize", "argument 'name'", "str", args
[0]);
1511 Py_ssize_t name_length
;
1512 name
= PyUnicode_AsUTF8AndSize(args
[0], &name_length
);
1516 if (strlen(name
) != (size_t)name_length
) {
1517 PyErr_SetString(PyExc_ValueError
, "embedded null character");
1520 skip_optional_kwonly
:
1521 return_value
= serialize_impl(self
, name
);
1524 return return_value
;
1527 #endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */
1529 #if defined(PY_SQLITE_HAVE_SERIALIZE)
1531 PyDoc_STRVAR(deserialize__doc__
,
1532 "deserialize($self, data, /, *, name=\'main\')\n"
1535 "Load a serialized database.\n"
1538 " The serialized database content.\n"
1540 " Which database to reopen with the deserialization.\n"
1542 "The deserialize interface causes the database connection to disconnect from the\n"
1543 "target database, and then reopen it as an in-memory database based on the given\n"
1544 "serialized data.\n"
1546 "The deserialize interface will fail with SQLITE_BUSY if the database is\n"
1547 "currently in a read transaction or is involved in a backup operation.");
1549 #define DESERIALIZE_METHODDEF \
1550 {"deserialize", _PyCFunction_CAST(deserialize), METH_FASTCALL|METH_KEYWORDS, deserialize__doc__},
1553 deserialize_impl(pysqlite_Connection
*self
, Py_buffer
*data
,
1557 deserialize(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
, PyObject
*kwnames
)
1559 PyObject
*return_value
= NULL
;
1560 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1562 #define NUM_KEYWORDS 1
1564 PyGC_Head _this_is_not_used
;
1566 PyObject
*ob_item
[NUM_KEYWORDS
];
1568 .ob_base
= PyVarObject_HEAD_INIT(&PyTuple_Type
, NUM_KEYWORDS
)
1569 .ob_item
= { &_Py_ID(name
), },
1572 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1574 #else // !Py_BUILD_CORE
1575 # define KWTUPLE NULL
1576 #endif // !Py_BUILD_CORE
1578 static const char * const _keywords
[] = {"", "name", NULL
};
1579 static _PyArg_Parser _parser
= {
1580 .keywords
= _keywords
,
1581 .fname
= "deserialize",
1585 PyObject
*argsbuf
[2];
1586 Py_ssize_t noptargs
= nargs
+ (kwnames
? PyTuple_GET_SIZE(kwnames
) : 0) - 1;
1587 Py_buffer data
= {NULL
, NULL
};
1588 const char *name
= "main";
1590 args
= _PyArg_UnpackKeywords(args
, nargs
, NULL
, kwnames
, &_parser
, 1, 1, 0, argsbuf
);
1594 if (PyUnicode_Check(args
[0])) {
1596 const char *ptr
= PyUnicode_AsUTF8AndSize(args
[0], &len
);
1600 if (PyBuffer_FillInfo(&data
, args
[0], (void *)ptr
, len
, 1, PyBUF_SIMPLE
) < 0) {
1604 else { /* any bytes-like object */
1605 if (PyObject_GetBuffer(args
[0], &data
, PyBUF_SIMPLE
) != 0) {
1610 goto skip_optional_kwonly
;
1612 if (!PyUnicode_Check(args
[1])) {
1613 _PyArg_BadArgument("deserialize", "argument 'name'", "str", args
[1]);
1616 Py_ssize_t name_length
;
1617 name
= PyUnicode_AsUTF8AndSize(args
[1], &name_length
);
1621 if (strlen(name
) != (size_t)name_length
) {
1622 PyErr_SetString(PyExc_ValueError
, "embedded null character");
1625 skip_optional_kwonly
:
1626 return_value
= deserialize_impl(self
, &data
, name
);
1629 /* Cleanup for data */
1631 PyBuffer_Release(&data
);
1634 return return_value
;
1637 #endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */
1639 PyDoc_STRVAR(pysqlite_connection_enter__doc__
,
1640 "__enter__($self, /)\n"
1643 "Called when the connection is used as a context manager.\n"
1645 "Returns itself as a convenience to the caller.");
1647 #define PYSQLITE_CONNECTION_ENTER_METHODDEF \
1648 {"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS, pysqlite_connection_enter__doc__},
1651 pysqlite_connection_enter_impl(pysqlite_Connection
*self
);
1654 pysqlite_connection_enter(pysqlite_Connection
*self
, PyObject
*Py_UNUSED(ignored
))
1656 return pysqlite_connection_enter_impl(self
);
1659 PyDoc_STRVAR(pysqlite_connection_exit__doc__
,
1660 "__exit__($self, type, value, traceback, /)\n"
1663 "Called when the connection is used as a context manager.\n"
1665 "If there was any exception, a rollback takes place; otherwise we commit.");
1667 #define PYSQLITE_CONNECTION_EXIT_METHODDEF \
1668 {"__exit__", _PyCFunction_CAST(pysqlite_connection_exit), METH_FASTCALL, pysqlite_connection_exit__doc__},
1671 pysqlite_connection_exit_impl(pysqlite_Connection
*self
, PyObject
*exc_type
,
1672 PyObject
*exc_value
, PyObject
*exc_tb
);
1675 pysqlite_connection_exit(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
)
1677 PyObject
*return_value
= NULL
;
1679 PyObject
*exc_value
;
1682 if (!_PyArg_CheckPositional("__exit__", nargs
, 3, 3)) {
1686 exc_value
= args
[1];
1688 return_value
= pysqlite_connection_exit_impl(self
, exc_type
, exc_value
, exc_tb
);
1691 return return_value
;
1694 PyDoc_STRVAR(setlimit__doc__
,
1695 "setlimit($self, category, limit, /)\n"
1698 "Set connection run-time limits.\n"
1701 " The limit category to be set.\n"
1703 " The new limit. If the new limit is a negative number, the limit is\n"
1706 "Attempts to increase a limit above its hard upper bound are silently truncated\n"
1707 "to the hard upper bound. Regardless of whether or not the limit was changed,\n"
1708 "the prior value of the limit is returned.");
1710 #define SETLIMIT_METHODDEF \
1711 {"setlimit", _PyCFunction_CAST(setlimit), METH_FASTCALL, setlimit__doc__},
1714 setlimit_impl(pysqlite_Connection
*self
, int category
, int limit
);
1717 setlimit(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
)
1719 PyObject
*return_value
= NULL
;
1723 if (!_PyArg_CheckPositional("setlimit", nargs
, 2, 2)) {
1726 category
= PyLong_AsInt(args
[0]);
1727 if (category
== -1 && PyErr_Occurred()) {
1730 limit
= PyLong_AsInt(args
[1]);
1731 if (limit
== -1 && PyErr_Occurred()) {
1734 return_value
= setlimit_impl(self
, category
, limit
);
1737 return return_value
;
1740 PyDoc_STRVAR(getlimit__doc__
,
1741 "getlimit($self, category, /)\n"
1744 "Get connection run-time limits.\n"
1747 " The limit category to be queried.");
1749 #define GETLIMIT_METHODDEF \
1750 {"getlimit", (PyCFunction)getlimit, METH_O, getlimit__doc__},
1753 getlimit_impl(pysqlite_Connection
*self
, int category
);
1756 getlimit(pysqlite_Connection
*self
, PyObject
*arg
)
1758 PyObject
*return_value
= NULL
;
1761 category
= PyLong_AsInt(arg
);
1762 if (category
== -1 && PyErr_Occurred()) {
1765 return_value
= getlimit_impl(self
, category
);
1768 return return_value
;
1771 PyDoc_STRVAR(setconfig__doc__
,
1772 "setconfig($self, op, enable=True, /)\n"
1775 "Set a boolean connection configuration option.\n"
1778 " The configuration verb; one of the sqlite3.SQLITE_DBCONFIG codes.");
1780 #define SETCONFIG_METHODDEF \
1781 {"setconfig", _PyCFunction_CAST(setconfig), METH_FASTCALL, setconfig__doc__},
1784 setconfig_impl(pysqlite_Connection
*self
, int op
, int enable
);
1787 setconfig(pysqlite_Connection
*self
, PyObject
*const *args
, Py_ssize_t nargs
)
1789 PyObject
*return_value
= NULL
;
1793 if (!_PyArg_CheckPositional("setconfig", nargs
, 1, 2)) {
1796 op
= PyLong_AsInt(args
[0]);
1797 if (op
== -1 && PyErr_Occurred()) {
1803 enable
= PyObject_IsTrue(args
[1]);
1808 return_value
= setconfig_impl(self
, op
, enable
);
1811 return return_value
;
1814 PyDoc_STRVAR(getconfig__doc__
,
1815 "getconfig($self, op, /)\n"
1818 "Query a boolean connection configuration option.\n"
1821 " The configuration verb; one of the sqlite3.SQLITE_DBCONFIG codes.");
1823 #define GETCONFIG_METHODDEF \
1824 {"getconfig", (PyCFunction)getconfig, METH_O, getconfig__doc__},
1827 getconfig_impl(pysqlite_Connection
*self
, int op
);
1830 getconfig(pysqlite_Connection
*self
, PyObject
*arg
)
1832 PyObject
*return_value
= NULL
;
1836 op
= PyLong_AsInt(arg
);
1837 if (op
== -1 && PyErr_Occurred()) {
1840 _return_value
= getconfig_impl(self
, op
);
1841 if ((_return_value
== -1) && PyErr_Occurred()) {
1844 return_value
= PyBool_FromLong((long)_return_value
);
1847 return return_value
;
1850 #ifndef CREATE_WINDOW_FUNCTION_METHODDEF
1851 #define CREATE_WINDOW_FUNCTION_METHODDEF
1852 #endif /* !defined(CREATE_WINDOW_FUNCTION_METHODDEF) */
1854 #ifndef PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
1855 #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
1856 #endif /* !defined(PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF) */
1858 #ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
1859 #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
1860 #endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
1862 #ifndef SERIALIZE_METHODDEF
1863 #define SERIALIZE_METHODDEF
1864 #endif /* !defined(SERIALIZE_METHODDEF) */
1866 #ifndef DESERIALIZE_METHODDEF
1867 #define DESERIALIZE_METHODDEF
1868 #endif /* !defined(DESERIALIZE_METHODDEF) */
1869 /*[clinic end generated code: output=7d41a178b7b2b683 input=a9049054013a1b77]*/