1import sqlite3
2
3con = sqlite3.connect(":memory:")
4
5# enable extension loading
6con.enable_load_extension(True)
7
8# Load the fulltext search extension
9con.execute("select load_extension('./fts3.so')")
10
11# alternatively you can load the extension using an API call:
12# con.load_extension("./fts3.so")
13
14# disable extension loading again
15con.enable_load_extension(False)
16
17# example from SQLite wiki
18con.execute("create virtual table recipe using fts3(name, ingredients)")
19con.executescript("""
20    insert into recipe (name, ingredients) values ('broccoli stew', 'broccoli peppers cheese tomatoes');
21    insert into recipe (name, ingredients) values ('pumpkin stew', 'pumpkin onions garlic celery');
22    insert into recipe (name, ingredients) values ('broccoli pie', 'broccoli cheese onions flour');
23    insert into recipe (name, ingredients) values ('pumpkin pie', 'pumpkin sugar flour butter');
24    """)
25for row in con.execute("select rowid, name, ingredients from recipe where name match 'pie'"):
26    print(row)
27
28con.close()
29