Skip to content
Closed
Changes from all commits
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
11 changes: 10 additions & 1 deletion Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ be used to implement an `object relational mapping

The essential idea is that the data is stored in an external database. The
Python instances only hold keys to the database's tables. Descriptors take
care of lookups or updates:
care of lookups or updates*:

.. testcode::

Expand All @@ -870,6 +870,15 @@ care of lookups or updates:
conn.execute(self.store, [value, obj.key])
conn.commit()

.. note::
Formatting string is not recommended for building SQL queries.
Since it is just an example and we didn't want to make the code
more complicated (in fact, using them in our example is quite justified),
we decided to use it. You have to validate the data before putting it
into a query string or trust an end-user, which sometimes is not the best
option. Use placeholders instead, as we did in ``WHERE`` clause.


We can use the :class:`Field` class to define `models
<https://en.wikipedia.org/wiki/Database_model>`_ that describe the schema for
each table in a database:
Expand Down