mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-91602: Add iterdump() support for filtering database objects (#114501)
Add optional 'filter' parameter to iterdump() that allows a "LIKE" pattern for filtering database objects to dump. Co-authored-by: Erlend E. Aasland <erlend@python.org>
This commit is contained in:
parent
4bf41879d0
commit
1a10437a14
11 changed files with 176 additions and 17 deletions
|
|
@ -1979,12 +1979,17 @@ finally:
|
|||
/*[clinic input]
|
||||
_sqlite3.Connection.iterdump as pysqlite_connection_iterdump
|
||||
|
||||
*
|
||||
filter: object = None
|
||||
An optional LIKE pattern for database objects to dump
|
||||
|
||||
Returns iterator to the dump of the database in an SQL text format.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
pysqlite_connection_iterdump_impl(pysqlite_Connection *self)
|
||||
/*[clinic end generated code: output=586997aaf9808768 input=1911ca756066da89]*/
|
||||
pysqlite_connection_iterdump_impl(pysqlite_Connection *self,
|
||||
PyObject *filter)
|
||||
/*[clinic end generated code: output=fd81069c4bdeb6b0 input=4ae6d9a898f108df]*/
|
||||
{
|
||||
if (!pysqlite_check_connection(self)) {
|
||||
return NULL;
|
||||
|
|
@ -1998,9 +2003,16 @@ pysqlite_connection_iterdump_impl(pysqlite_Connection *self)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *retval = PyObject_CallOneArg(iterdump, (PyObject *)self);
|
||||
PyObject *args[3] = {NULL, (PyObject *)self, filter};
|
||||
PyObject *kwnames = Py_BuildValue("(s)", "filter");
|
||||
if (!kwnames) {
|
||||
Py_DECREF(iterdump);
|
||||
return NULL;
|
||||
}
|
||||
Py_ssize_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
|
||||
PyObject *retval = PyObject_Vectorcall(iterdump, args + 1, nargsf, kwnames);
|
||||
Py_DECREF(iterdump);
|
||||
Py_DECREF(kwnames);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue