Pelokalan
Python ID
id en
Masuk
Proyek
library__sqlite3.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
For example:
Sebagai contoh:
Pass this flag value to the *detect_types* parameter of :func:`connect` to look up a converter function using the declared types for each column. The types are declared when the database table is created. :mod:`!sqlite3` will look up a converter function using the first word of the declared type as the converter dictionary key. For example:
Generated fields (for example ``MAX(p)``) are returned as :class:`str`. Use :const:`!PARSE_COLNAMES` to enforce types for such queries.
Register :term:`callable` *progress_handler* to be invoked for every *n* instructions of the SQLite virtual machine. This is useful if you want to get called from SQLite during long-running operations, for example to update a GUI.
This exception is not currently raised by the :mod:`!sqlite3` module, but may be raised by applications using :mod:`!sqlite3`, for example if a user-defined function truncates data while inserting. ``Warning`` is a subclass of :exc:`Exception`.
Exception raised for errors that are related to the database's operation, and not necessarily under the control of the programmer. For example, the database path is not found, or a transaction could not be processed. ``OperationalError`` is a subclass of :exc:`DatabaseError`.
Exception raised for :mod:`!sqlite3` API programming errors, for example supplying the wrong number of bindings to a query, or trying to operate on a closed :class:`Connection`. ``ProgrammingError`` is a subclass of :exc:`DatabaseError`.
Exception raised in case a method or database API is not supported by the underlying SQLite library. For example, setting *deterministic* to ``True`` in :meth:`~Connection.create_function`, if the underlying SQLite library does not support deterministic functions. ``NotSupportedError`` is a subclass of :exc:`DatabaseError`.
SQL operations usually need to use values from Python variables. However, beware of using Python's string operations to assemble queries, as they are vulnerable to `SQL injection attacks`_. For example, an attacker can simply close the single quote and inject ``OR TRUE`` to select all rows::
Because of SQLite's `flexible typing`_, it is not uncommon to encounter table columns with the ``TEXT`` data type containing non-UTF-8 encodings, or even arbitrary data. To demonstrate, let's assume we have a database with ISO-8859-2 (Latin-2) encoded text, for example a table of Czech-English dictionary entries. Assuming we now have a :class:`Connection` instance :py:data:`!con` connected to this database, we can decode the Latin-2 encoded text using this :attr:`~Connection.text_factory`: