diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index c017dacff88976..443773dd97a01b 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -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. @@ -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 `_, which @@ -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. diff --git a/Misc/NEWS.d/next/Library/2021-02-09-20-03-40.bpo-43094.HVV-X5.rst b/Misc/NEWS.d/next/Library/2021-02-09-20-03-40.bpo-43094.HVV-X5.rst new file mode 100644 index 00000000000000..92bbe8c1535cc8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-02-09-20-03-40.bpo-43094.HVV-X5.rst @@ -0,0 +1,2 @@ +Update :mod:`sqlite3` documentation and docstrings to match implementation. +Patch by Erlend E. Aasland. diff --git a/Modules/_sqlite/clinic/connection.c.h b/Modules/_sqlite/clinic/connection.c.h index 01b8e37a957fc2..47b719a7b128cf 100644 --- a/Modules/_sqlite/clinic/connection.c.h +++ b/Modules/_sqlite/clinic/connection.c.h @@ -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."); @@ -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]*/ diff --git a/Modules/_sqlite/clinic/module.c.h b/Modules/_sqlite/clinic/module.c.h index fb1e1187b209f8..4cc25b32b192fe 100644 --- a/Modules/_sqlite/clinic/module.c.h +++ b/Modules/_sqlite/clinic/module.c.h @@ -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."); @@ -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."); @@ -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."); @@ -181,7 +181,8 @@ pysqlite_enable_callback_trace(PyObject *module, PyObject *arg) } PyDoc_STRVAR(pysqlite_adapt__doc__, -"adapt($module, obj, proto=PrepareProtocolType, alt=, /)\n" +"adapt($module, obj, protocol=PrepareProtocolType,\n" +" alternate=, /)\n" "--\n" "\n" "Adapt given object to given protocol. Non-standard."); @@ -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]*/ diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 370dc1a30e46a1..889dee95abf5c2 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -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. @@ -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; diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c index 6bfb1b73f82391..89cc58a9eed2e6 100644 --- a/Modules/_sqlite/module.c +++ b/Modules/_sqlite/module.c @@ -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. @@ -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; @@ -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. @@ -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; @@ -222,7 +222,7 @@ 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. @@ -230,7 +230,7 @@ Enable or disable callback functions throwing errors to stderr. 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; @@ -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. @@ -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); }