summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGerhard Häring <gh@ghaering.de>2010-03-05 09:12:37 (GMT)
committerGerhard Häring <gh@ghaering.de>2010-03-05 09:12:37 (GMT)
commit3bbb67273a8c146a38de91080a37e716e2699622 (patch)
tree19a3d1e79cb51cc42760af73724c4f4615d4c21c /Doc
parent2bb66e03b72ae5a0468dab0b7020316f31c8cfdf (diff)
downloadcpython-3bbb67273a8c146a38de91080a37e716e2699622.zip
cpython-3bbb67273a8c146a38de91080a37e716e2699622.tar.gz
cpython-3bbb67273a8c146a38de91080a37e716e2699622.tar.bz2
Merged code from pysqlite 2.6.0.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/includes/sqlite3/load_extension.py26
-rw-r--r--Doc/library/sqlite3.rst21
2 files changed, 46 insertions, 1 deletions
diff --git a/Doc/includes/sqlite3/load_extension.py b/Doc/includes/sqlite3/load_extension.py
new file mode 100644
index 0000000..7f893c9
--- /dev/null
+++ b/Doc/includes/sqlite3/load_extension.py
@@ -0,0 +1,26 @@
+import sqlite3
+
+con = sqlite3.connect(":memory:")
+
+# enable extension loading
+con.enable_load_extension(True)
+
+# Load the fulltext search extension
+con.execute("select load_extension('./fts3.so')")
+
+# alternatively you can load the extension using an API call:
+# con.load_extension("./fts3.so")
+
+# disable extension laoding again
+con.enable_load_extension(False)
+
+# example from SQLite wiki
+con.execute("create virtual table recipe using fts3(name, ingredients)")
+con.executescript("""
+ insert into recipe (name, ingredients) values ('broccoli stew', 'broccoli peppers cheese tomatoes');
+ insert into recipe (name, ingredients) values ('pumpkin stew', 'pumpkin onions garlic celery');
+ insert into recipe (name, ingredients) values ('broccoli pie', 'broccoli cheese onions flour');
+ insert into recipe (name, ingredients) values ('pumpkin pie', 'pumpkin sugar flour butter');
+ """)
+for row in con.execute("select rowid, name, ingredients from recipe where name match 'pie'"):
+ print row
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 8ccb0ab..439ca23 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -368,6 +368,25 @@ Connection Objects
method with :const:`None` for *handler*.
+.. method:: Connection.enable_load_extension(enabled)
+
+ .. versionadded:: 2.7
+
+ 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:: 2.7
+
+ 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
@@ -439,7 +458,7 @@ Connection Objects
Cursor Objects
--------------
-.. class:: Cursor
+A :class:`Cursor` instance has the following attributes and methods:
A SQLite database cursor has the following attributes and methods: