| 1 |
import sqlite3 |
| 2 |
|
| 3 |
con = sqlite3.connect(":memory:") |
| 4 |
|
| 5 |
|
| 6 |
con.enable_load_extension(True) |
| 7 |
|
| 8 |
|
| 9 |
con.execute("select load_extension('./fts3.so')") |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
con.enable_load_extension(False) |
| 16 |
|
| 17 |
|
| 18 |
con.execute("create virtual table recipe using fts3(name, ingredients)") |
| 19 |
con.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 |
""") |
| 25 |
for row in con.execute("select rowid, name, ingredients from recipe where name match 'pie'"): |
| 26 |
print row |