Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@ Connection Objects

.. class:: Connection

Each open SQLite database is represented by a connection object.
A connection object is created with :func:`sqlite3.connect`.
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
The main purpose of connection objects is creating
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
:class:`cursors objects <Cursor>`,
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
and :ref:`sqlite3-controlling-transactions`.

.. seealso::

* :ref:`sqlite3-connection-shortcuts`
* :ref:`sqlite3-connection-context-manager`

An SQLite database connection has the following attributes and methods:

.. attribute:: isolation_level
Expand Down Expand Up @@ -957,6 +968,20 @@ Connection Objects
Cursor Objects
--------------

A cursor object represents a database cursor,
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
which is used to execute SQL statements,
and manage the context of a fetch operation.
Cursors are created with :meth:`Connection.cursor`,
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
or by using any of the :ref:`connection shortcut methods
<sqlite3-connection-shortcuts>`.

Cursors objects are :term:`iterators <iterator>`,
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
meaning that if you :meth:`execute` a ``SELECT`` query,
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
you can simply iterate over the cursor to fetch the resulting rows::

for row in cur.execute("select * from data"):
print(row)

.. class:: Cursor

A :class:`Cursor` instance has the following attributes and methods.
Expand Down Expand Up @@ -1111,15 +1136,13 @@ Row Objects

.. class:: Row

A :class:`Row` instance serves as a highly optimized
A :class:`Row` instance that serves as a highly optimized
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
:attr:`~Connection.row_factory` for :class:`Connection` objects.
It tries to mimic a tuple in most of its features.

It supports mapping access by column name and index, iteration,
It tries to mimic a :class:`tuple` in most of its features,
Comment thread
erlend-aasland marked this conversation as resolved.
and supports :term:`mapping` access by column name and index, iteration,
representation, equality testing and :func:`len`.
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated

If two :class:`Row` objects have exactly the same columns and their
members are equal, they compare equal.
Two row objects are equal if they have equal columns and equal members.
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated

.. method:: keys

Expand Down Expand Up @@ -1618,8 +1641,10 @@ Using :mod:`sqlite3` efficiently
--------------------------------


Using shortcut methods
^^^^^^^^^^^^^^^^^^^^^^
.. _sqlite3-connection-shortcuts:

Using connection shortcut methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Using the nonstandard :meth:`execute`, :meth:`executemany` and
:meth:`executescript` methods of the :class:`Connection` object, your code can
Expand Down