diff options
author | Gerhard Häring <gh@ghaering.de> | 2010-03-05 15:20:03 (GMT) |
---|---|---|
committer | Gerhard Häring <gh@ghaering.de> | 2010-03-05 15:20:03 (GMT) |
commit | f9cee224461273307ca9f8a0e690a527496534ab (patch) | |
tree | c12745138703eba02cc59f892cf9f19db6cd7ff5 /Doc/includes | |
parent | 06dbff3b1f16dc232df0190cfed4b3af81aecda3 (diff) | |
download | cpython-f9cee224461273307ca9f8a0e690a527496534ab.zip cpython-f9cee224461273307ca9f8a0e690a527496534ab.tar.gz cpython-f9cee224461273307ca9f8a0e690a527496534ab.tar.bz2 |
Merged new pysqlite version 2.6.0 from trunk.
Diffstat (limited to 'Doc/includes')
-rw-r--r-- | Doc/includes/sqlite3/load_extension.py | 26 |
1 files changed, 26 insertions, 0 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 |