Mercurial > cpython-lru_cache-weakref
diff Doc/includes/sqlite3/load_extension.py @ 59372:3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
| author | Gerhard Häring <gh@ghaering.de> |
|---|---|
| date | Fri, 05 Mar 2010 15:20:03 +0000 |
| parents | |
| children | 74d81a3a0d56 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/includes/sqlite3/load_extension.py Fri Mar 05 15:20:03 2010 +0000 @@ -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
