3

In order to make Levensthein distance (string similary) work with Sqlite on Windows, I either:

  • need to find a Sqlite binary version that has spellfix1 module already included

  • or to recompile the whole Sqlite for Windows with this module,

  • or to compile just this module.

The final goal is to load it in Python via:

import sqlite3
db = sqlite3.connect(':memory:')
db.enable_load_extension(True)
db.load_extension('./spellfix')
db.enable_load_extension(False)
...
c.execute('SELECT * FROM mytable WHERE editdist3(description, "Hello wrld") < 3')

Question:

Should I recompile the whole Sqlite for Windows, and replace C:\Python27\DLLs\_sqlite3.pyd by the new one? If so, how? and is it safe to expect that Python will accept this newly-compiled _sqlite3.pyd file?
Or should I keep the old C:\Python27\DLLs\_sqlite3.pyd and just compile the external module spellfix1? How?

What I've tried so far:

  • Download https://sqlite.org/2016/sqlite-src-3110100.zip, unzip it
  • Run this:

    call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
    cl ext\misc\spellfix.c
    

    ext\misc\spellfix.c(17) : fatal error C1083: Cannot open include file: 'sqlite3ext.h': No such file or directory

    Where to find the headers, and where to specify these headers in cl.exe ...?

Note: this is for Linux but I couldn't do the same on Windows.

Basj
  • 41,386
  • 99
  • 383
  • 673
  • You may find this useful: http://sqlite.1065341.n5.nabble.com/Spellfix-Implementation-td75596.html. I would only compile `spellfix1` with minGW and try to load it first. – Jacques Gaudin Apr 12 '18 at 16:44
  • @JacquesGaudin do you think it would work into Python, or should I recompile the whole `sqlite3` python module? – Basj Apr 12 '18 at 16:51
  • My guess is that if you can load it in sqlite it will work from python as the `load_extension` method is just a binding to the original C method. – Jacques Gaudin Apr 12 '18 at 17:11
  • 1
    Luckily I am on a Windows machine and I managed to get MinGw to work. I could compile using `gcc -g -shared spellfix.c -I ~/sqlite-amalgation-3230100/ -o spellfix.dll`. Basically the error you get is msvc trying to find the include files in the amalgation package `sqlite3.h` and `sqlite3ext.h`. Use the `cl /I ext\misc\spellfix.c`... or something similar! – Jacques Gaudin Apr 13 '18 at 09:47
  • @JacquesGaudin Thanks for your answer, I tried with `/I ...`, and it can find the .h now, but it still doesnt work: https://stackoverflow.com/questions/49813006/cl-exe-error-d8003-missing-source-filename-when-building-a-sqlite-module – Basj Apr 13 '18 at 09:50
  • 1
    I got it to work with `cl` and posted the command on your other question. – Jacques Gaudin Apr 13 '18 at 10:37

0 Answers0