tips:sqlite

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tips:sqlite [2020/01/21 16:08] – created scipiotips:sqlite [2020/01/22 09:46] (current) scipio
Line 1: Line 1:
 ====== sqlite ====== ====== sqlite ======
  
-compile from sources +compile from sources into a python virtualenv (or change PREFIX to /usr/local) with spellfix extension 
-<code> +<code bash
-git clone https://github.com/sqlite/sqlite.git+cd /tmp 
 + 
 +if [ ! -d sqlite ]; then 
 +    [ -f sqlite.tar.gz ] || wget https://www.sqlite.org/src/tarball/sqlite.tar.gz 
 +    tar zxf sqlite.tar.gz 
 +fi 
 cd sqlite cd sqlite
-mkdir build +export CFLAGS="-DSQLITE_ENABLE_FTS3 \ 
-cd build +    -DSQLITE_ENABLE_FTS3_PARENTHESIS \ 
-../configure +    -DSQLITE_ENABLE_FTS4 \ 
-make -j4 +    -DSQLITE_ENABLE_FTS5 \ 
-gcc -shared -fPIC -Wall -I ./tsrc ../sqlite/ext/misc/spellfix.c -o spellfix.so +    -DSQLITE_ENABLE_JSON1 \ 
-  +    -DSQLITE_ENABLE_LOAD_EXTENSION \ 
 +    -DSQLITE_ENABLE_RTREE \ 
 +    -DSQLITE_ENABLE_STAT4 \ 
 +    -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ 
 +    -DSQLITE_SOUNDEX \ 
 +    -DSQLITE_TEMP_STORE=3 \ 
 +    -DSQLITE_USE_URI \ 
 +    -O2 \ 
 +    -fPIC" 
 + 
 +export PREFIX="${VIRTUAL_ENV}" 
 +LIBS="-lm" ./configure --disable-tcl --enable-shared --enable-tempstore=always --prefix="$PREFIX" 
 +make -j4 && \ 
 +make install && \ 
 +gcc -shared -fPIC -Wall -O2 -I ./ ext/misc/spellfix.c -o ${PREFIX}/lib/spellfix.so 
 + 
 +echo "Add 'export LD_LIBRARY_PATH=${VIRTUAL_ENV}/lib:$LD_LIBRARY_PATH' to your environment" 
 </code> </code>
  
 <file python test.py> <file python test.py>
 import sqlite3 import sqlite3
 +
 db = sqlite3.connect(':memory:') db = sqlite3.connect(':memory:')
 db.enable_load_extension(True) db.enable_load_extension(True)
-db.load_extension('./spellfix'                # for Linux+db.load_extension('spellfix'                # for Linux
 db.enable_load_extension(False) db.enable_load_extension(False)
 c = db.cursor() c = db.cursor()
Line 25: Line 49:
 c.execute('SELECT * FROM mytable WHERE editdist3(description, "hel o wrold guy") < 600') c.execute('SELECT * FROM mytable WHERE editdist3(description, "hel o wrold guy") < 600')
 print(c.fetchall()) print(c.fetchall())
-</code>+</file>
  
  
  • tips/sqlite.1579619313.txt.gz
  • Last modified: 2020/01/21 16:08
  • by scipio