ยปCore Development>Code coverage>Doc/includes/sqlite3/load_extension.py

Python code coverage for Doc/includes/sqlite3/load_extension.py

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