Staging
v0.5.1
https://github.com/python/cpython
Revision 87e691240b5b16b622a6e91acea89673de601d63 authored by Raymond Hettinger on 03 March 2015, 07:32:02 UTC, committed by Raymond Hettinger on 03 March 2015, 07:32:02 UTC
1 parent f9d9c79
Raw File
Tip revision: 87e691240b5b16b622a6e91acea89673de601d63 authored by Raymond Hettinger on 03 March 2015, 07:32:02 UTC
Minor neatening-up. Make assignments in same order a struct fields. Line-up comments.
Tip revision: 87e6912
load_extension.py
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)
back to top