Skip to content

bpo-43094: Update sqlite3 docs to match implementation #24489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
16 changes: 8 additions & 8 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ Module functions and constants
float, str or bytes.


.. function:: complete_statement(sql)
.. function:: complete_statement(statement)

Returns :const:`True` if the string *sql* contains one or more complete SQL
statements terminated by semicolons. It does not verify that the SQL is
Returns :const:`True` if the string *statement* contains one or more complete
SQL statements terminated by semicolons. It does not verify that the SQL is
syntactically correct, only that there are no unclosed string literals and the
statement is terminated by a semicolon.

Expand Down Expand Up @@ -339,11 +339,11 @@ Connection Objects
:meth:`~Cursor.executescript` method with the given *sql_script*, and
returns the cursor.

.. method:: create_function(name, num_params, func, *, deterministic=False)
.. method:: create_function(name, narg, func, *, deterministic=False)

Creates a user-defined function that you can later use from within SQL
statements under the function name *name*. *num_params* is the number of
parameters the function accepts (if *num_params* is -1, the function may
statements under the function name *name*. *narg* is the number of
parameters the function accepts (if *narg* is -1, the function may
take any number of arguments), and *func* is a Python callable that is
called as the SQL function. If *deterministic* is true, the created function
is marked as `deterministic <https://sqlite.org/deterministic.html>`_, which
Expand All @@ -362,12 +362,12 @@ Connection Objects
.. literalinclude:: ../includes/sqlite3/md5func.py


.. method:: create_aggregate(name, num_params, aggregate_class)
.. method:: create_aggregate(name, n_arg, aggregate_class)

Creates a user-defined aggregate function.

The aggregate class must implement a ``step`` method, which accepts the number
of parameters *num_params* (if *num_params* is -1, the function may take
of parameters *n_arg* (if *n_arg* is -1, the function may take
any number of arguments), and a ``finalize`` method which will return the
final result of the aggregate.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update :mod:`sqlite3` documentation and docstrings to match implementation.
Patch by Erlend E. Aasland.
4 changes: 2 additions & 2 deletions Modules/_sqlite/clinic/connection.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *const *args, Py_
}

PyDoc_STRVAR(pysqlite_connection_create_collation__doc__,
"create_collation($self, name, callback, /)\n"
"create_collation($self, name, callable, /)\n"
"--\n"
"\n"
"Creates a collation function. Non-standard.");
Expand Down Expand Up @@ -719,4 +719,4 @@ pysqlite_connection_exit(pysqlite_Connection *self, PyObject *const *args, Py_ss
#ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
#define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
#endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
/*[clinic end generated code: output=7cb13d491a5970aa input=a9049054013a1b77]*/
/*[clinic end generated code: output=05a4311700956cfb input=a9049054013a1b77]*/
11 changes: 6 additions & 5 deletions Modules/_sqlite/clinic/module.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pysqlite_enable_shared_cache(PyObject *module, PyObject *const *args, Py_ssize_t
}

PyDoc_STRVAR(pysqlite_register_adapter__doc__,
"register_adapter($module, type, caster, /)\n"
"register_adapter($module, type, callable, /)\n"
"--\n"
"\n"
"Registers an adapter with pysqlite\'s adapter registry. Non-standard.");
Expand Down Expand Up @@ -115,7 +115,7 @@ pysqlite_register_adapter(PyObject *module, PyObject *const *args, Py_ssize_t na
}

PyDoc_STRVAR(pysqlite_register_converter__doc__,
"register_converter($module, name, converter, /)\n"
"register_converter($module, typename, callable, /)\n"
"--\n"
"\n"
"Registers a converter with pysqlite. Non-standard.");
Expand Down Expand Up @@ -153,7 +153,7 @@ pysqlite_register_converter(PyObject *module, PyObject *const *args, Py_ssize_t
}

PyDoc_STRVAR(pysqlite_enable_callback_trace__doc__,
"enable_callback_tracebacks($module, enable, /)\n"
"enable_callback_tracebacks($module, flag, /)\n"
"--\n"
"\n"
"Enable or disable callback functions throwing errors to stderr.");
Expand Down Expand Up @@ -181,7 +181,8 @@ pysqlite_enable_callback_trace(PyObject *module, PyObject *arg)
}

PyDoc_STRVAR(pysqlite_adapt__doc__,
"adapt($module, obj, proto=PrepareProtocolType, alt=<unrepresentable>, /)\n"
"adapt($module, obj, protocol=PrepareProtocolType,\n"
" alternate=<unrepresentable>, /)\n"
"--\n"
"\n"
"Adapt given object to given protocol. Non-standard.");
Expand Down Expand Up @@ -219,4 +220,4 @@ pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=d87990f941c209fa input=a9049054013a1b77]*/
/*[clinic end generated code: output=508d362707c8654d input=a9049054013a1b77]*/
4 changes: 2 additions & 2 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
_sqlite3.Connection.create_collation as pysqlite_connection_create_collation

name: unicode
callback as callable: object
callable: object
/

Creates a collation function. Non-standard.
Expand All @@ -1711,7 +1711,7 @@ Creates a collation function. Non-standard.
static PyObject *
pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
PyObject *name, PyObject *callable)
/*[clinic end generated code: output=0f63b8995565ae22 input=5c3898813a776cf2]*/
/*[clinic end generated code: output=0f63b8995565ae22 input=4ec50c4866fd1f30]*/
{
PyObject* uppercase_name = 0;
Py_ssize_t i, len;
Expand Down
20 changes: 10 additions & 10 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pysqlite_enable_shared_cache_impl(PyObject *module, int do_enable)
_sqlite3.register_adapter as pysqlite_register_adapter

type: object(type='PyTypeObject *')
caster: object
callable as caster: object
/

Registers an adapter with pysqlite's adapter registry. Non-standard.
Expand All @@ -166,7 +166,7 @@ Registers an adapter with pysqlite's adapter registry. Non-standard.
static PyObject *
pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
PyObject *caster)
/*[clinic end generated code: output=a287e8db18e8af23 input=839dad90e2492725]*/
/*[clinic end generated code: output=a287e8db18e8af23 input=439a2d0779f8174d]*/
{
int rc;

Expand All @@ -187,8 +187,8 @@ pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
/*[clinic input]
_sqlite3.register_converter as pysqlite_register_converter

name as orig_name: unicode
converter as callable: object
typename as orig_name: unicode
callable: object
/

Registers a converter with pysqlite. Non-standard.
Expand All @@ -197,7 +197,7 @@ Registers a converter with pysqlite. Non-standard.
static PyObject *
pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
PyObject *callable)
/*[clinic end generated code: output=a2f2bfeed7230062 input=e074cf7f4890544f]*/
/*[clinic end generated code: output=a2f2bfeed7230062 input=438c60d0fadae4b1]*/
{
PyObject* name = NULL;
PyObject* retval = NULL;
Expand All @@ -222,15 +222,15 @@ pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
/*[clinic input]
_sqlite3.enable_callback_tracebacks as pysqlite_enable_callback_trace

enable: int
flag as enable: int
/

Enable or disable callback functions throwing errors to stderr.
[clinic start generated code]*/

static PyObject *
pysqlite_enable_callback_trace_impl(PyObject *module, int enable)
/*[clinic end generated code: output=4ff1d051c698f194 input=cb79d3581eb77c40]*/
/*[clinic end generated code: output=4ff1d051c698f194 input=50b5bf5224c327e9]*/
{
_pysqlite_enable_callback_tracebacks = enable;

Expand All @@ -241,8 +241,8 @@ pysqlite_enable_callback_trace_impl(PyObject *module, int enable)
_sqlite3.adapt as pysqlite_adapt

obj: object
proto: object(c_default='(PyObject*)pysqlite_PrepareProtocolType') = PrepareProtocolType
alt: object = NULL
protocol as proto: object(c_default='(PyObject*)pysqlite_PrepareProtocolType') = PrepareProtocolType
alternate as alt: object = NULL
/

Adapt given object to given protocol. Non-standard.
Expand All @@ -251,7 +251,7 @@ Adapt given object to given protocol. Non-standard.
static PyObject *
pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
PyObject *alt)
/*[clinic end generated code: output=0c3927c5fcd23dd9 input=a58ab77fb5ae22dd]*/
/*[clinic end generated code: output=0c3927c5fcd23dd9 input=e2389971eae0c359]*/
{
return pysqlite_microprotocols_adapt(obj, proto, alt);
}
Expand Down