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