tips:sqlite

This is an old revision of the document!


sqlite

compile from sources

git clone https://github.com/sqlite/sqlite.git
cd sqlite
mkdir build
cd build
../configure
make -j4
gcc -shared -fPIC -Wall -I ./tsrc ../sqlite/ext/misc/spellfix.c -o spellfix.so
  
test.py
import sqlite3
db = sqlite3.connect(':memory:')
db.enable_load_extension(True)
db.load_extension('./spellfix')                 # for Linux
db.enable_load_extension(False)
c = db.cursor()
c.execute('CREATE TABLE mytable (id integer, description text)')
c.execute('INSERT INTO mytable VALUES (1, "hello world, guys")')
c.execute('INSERT INTO mytable VALUES (2, "hello there everybody")')
c.execute('SELECT * FROM mytable WHERE editdist3(description, "hel o wrold guy") < 600')
print(c.fetchall())
  • tips/sqlite.1579619343.txt.gz
  • Last modified: 2020/01/21 16:09
  • by scipio