--- Doc/library/sqlite3.rst.old 2010-05-25 01:02:36.000000000 +0530 +++ Doc/library/sqlite3.rst.new 2010-05-25 01:04:07.000000000 +0530 @@ -79,18 +79,18 @@ >>> c = conn.cursor() >>> c.execute('select * from stocks order by price') >>> for row in c: - ... print(row) + ... print(row) ... - (u'2006-01-05', u'BUY', u'RHAT', 100, 35.14) - (u'2006-03-28', u'BUY', u'IBM', 1000, 45.0) - (u'2006-04-06', u'SELL', u'IBM', 500, 53.0) - (u'2006-04-05', u'BUY', u'MSOFT', 1000, 72.0) + ('2006-01-05', 'BUY', 'RHAT', 100, 35.14) + ('2006-03-28', 'BUY', 'IBM', 1000, 45.0) + ('2006-04-06', 'SELL', 'IBM', 500, 53.0) + ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.0) >>> .. seealso:: - http://www.pysqlite.org + http://code.google.com/p/pysqlite/ The pysqlite web page -- sqlite3 is developed externally under the name "pysqlite". @@ -187,7 +187,7 @@ Registers a callable to convert the custom Python type *type* into one of SQLite's supported types. The callable *callable* accepts as single parameter the Python value, and must return a value of the following types: int, - float, str, bytes (UTF-8 encoded) or buffer. + float, str or bytes. .. function:: complete_statement(sql) @@ -256,22 +256,23 @@ .. method:: Connection.execute(sql, [parameters]) This is a nonstandard shortcut that creates an intermediate cursor object by - calling the cursor method, then calls the cursor's :meth:`execute` method with - the parameters given. + calling the cursor method, then calls the cursor's + :meth:`execute` method with the parameters given. .. method:: Connection.executemany(sql, [parameters]) This is a nonstandard shortcut that creates an intermediate cursor object by - calling the cursor method, then calls the cursor's :meth:`executemany` method - with the parameters given. + calling the cursor method, then calls the cursor's + :meth:`executemany` method with the parameters given. .. method:: Connection.executescript(sql_script) This is a nonstandard shortcut that creates an intermediate cursor object by - calling the cursor method, then calls the cursor's :meth:`executescript` method - with the parameters given. + calling the cursor method, then calls the cursor's + :meth:`executescript` method with the parameters + given. .. method:: Connection.create_function(name, num_params, func) @@ -282,7 +283,7 @@ as the SQL function. The function can return any of the types supported by SQLite: bytes, str, int, - float, buffer and None. + float and None. Example: @@ -298,7 +299,7 @@ final result of the aggregate. The ``finalize`` method can return any of the types supported by SQLite: - bytes, str, int, float, buffer and None. + bytes, str, int, float and None. Example: @@ -364,6 +365,25 @@ method with :const:`None` for *handler*. +.. method:: Connection.enable_load_extension(enabled) + + .. versionadded:: 3.2 + + This routine allows/disallows the SQLite engine to load SQLite extensions + from shared libraries. SQLite extensions can define new functions, + aggregates or whole new virtual table implementations. One well-known + extension is the fulltext-search extension distributed with SQLite. + + .. literalinclude:: ../includes/sqlite3/load_extension.py + +.. method:: Connection.load_extension(path) + + .. versionadded:: 3.2 + + This routine loads a SQLite extension from a shared library. You have to + enable extension loading with ``enable_load_extension`` before you can use + this routine. + .. attribute:: Connection.row_factory You can change this attribute to a callable that accepts the cursor and the @@ -433,7 +453,7 @@ Cursor Objects -------------- -.. class:: Cursor +A :class:`Cursor` instance has the following attributes and methods: A SQLite database cursor has the following attributes and methods: @@ -589,18 +609,19 @@ >>> r = c.fetchone() >>> type(r) - - >>> r - (u'2006-01-05', u'BUY', u'RHAT', 100.0, 35.14) + + >>> tuple(r) + ('2006-01-05', 'BUY', 'RHAT', 100.0, 35.14) >>> len(r) 5 >>> r[2] - u'RHAT' + 'RHAT' >>> r.keys() ['date', 'trans', 'symbol', 'qty', 'price'] >>> r['qty'] 100.0 - >>> for member in r: print member + >>> for member in r: + ... print(member) ... 2006-01-05 BUY @@ -632,11 +653,9 @@ +-------------------------------+-------------+ | :class:`float` | ``REAL`` | +-------------------------------+-------------+ -| :class:`bytes` (UTF8-encoded) | ``TEXT`` | -+-------------------------------+-------------+ | :class:`str` | ``TEXT`` | +-------------------------------+-------------+ -| :class:`buffer` | ``BLOB`` | +| :class:`bytes` | ``BLOB`` | +-------------------------------+-------------+ @@ -647,13 +666,13 @@ +=============+=============================================+ | ``NULL`` | :const:`None` | +-------------+---------------------------------------------+ -| ``INTEGER`` | :class`int` | +| ``INTEGER`` | :class:`int` | +-------------+---------------------------------------------+ | ``REAL`` | :class:`float` | +-------------+---------------------------------------------+ | ``TEXT`` | depends on text_factory, str by default | +-------------+---------------------------------------------+ -| ``BLOB`` | buffer | +| ``BLOB`` | :class:`bytes` | +-------------+---------------------------------------------+ The type system of the :mod:`sqlite3` module is extensible in two ways: you can @@ -668,7 +687,7 @@ As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must **adapt** them to one of the sqlite3 module's supported types for SQLite: one of NoneType, int, float, -str, bytes, buffer. +str, bytes. The :mod:`sqlite3` module uses Python object adaptation, as described in :pep:`246` for this. The protocol to use is :class:`PrepareProtocol`.