Properly install sqlite3 with FTS5 support

前端 未结 3 731
误落风尘
误落风尘 2021-01-19 13:58

I\'m developing a Python tool which uses a sqlite3 virtual table with FTS5 (Full Text Search). I would like to know how to properly install from a tarball (or any other mean

3条回答
  •  忘掉有多难
    2021-01-19 14:24

    The easy way is to use apsw (Another Python SQLite Wrapper). Its API is just a little different from sqlite3 and you can't just pip-install it (unless you're okay with outdated version), but the rest is good and you can have the most recent features of SQLite.

    wget https://github.com/rogerbinns/apsw/releases/download/3.22.0-r1/apsw-3.22.0-r1.zip
    unzip apsw-3.22.0-r1.zip
    cd apsw-3.22.0-r1
    python setup.py fetch --sqlite build --enable-all-extensions install
    

    Then,

    import apsw
    
    apsw.Connection(':memory:').cursor().execute('pragma compile_options').fetchall()
    

    Returns:

    [('COMPILER=gcc-5.4.0 20160609',),
     ('ENABLE_API_ARMOR',),
     ('ENABLE_FTS3',),
     ('ENABLE_FTS3_PARENTHESIS',),
     ('ENABLE_FTS4',),
     ('ENABLE_FTS5',), 
     ('ENABLE_ICU',),
     ('ENABLE_JSON1',),
     ('ENABLE_RBU',),
     ('ENABLE_RTREE',),
     ('ENABLE_STAT4',),
     ('THREADSAFE=1',)]
    

    The hard way is to compile Python with custom SQLite. More detail in this article by Charles Leifer.

提交回复
热议问题