This is the code to attempt SQLAlchemy database reflection on a SQLite3 database with FTS tables that use a unicode61 tokenizer:
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///database.sqlite')
Base = declarative_base()
metadata = Base.metadata
metadata.reflect(bind=engine, views=True)
This error:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unknown tokenizer: unicode61
As of v3.8.6 this tokenizer is included by default and is not optionally compiled.
v3.8.6 The unicode61 tokenizer is now included in FTS4 by default.
Meanwhile when I run:
$ python
>>> import sqlite3
>>> sqite3.sqlite_version
'3.8.5'
... frick.
However:
$ sqlite3
SQLite version 3.9.2 2015-11-02 18:31:45
How do I get Python or SQLAlchemy in particular to reference a more modern or even custom compiled sqlite3 binary?
Additional note: I am trying to run on an OSX (10.10.5 Yosemite) system so as far as I can tell SQLAlchemy and Python are referencing pysqlite which is the dbapi2 wrapper for sqlite3.dylib. I have just found the following article which I will try and return with my results.
http://sqlite.1065341.n5.nabble.com/How-to-build-a-new-sqlite3-dylib-td63635.html
Results so far:
Renaming
/usr/lib/libsqlite3.dylib
in prep for replacing it with the custom build will brick OSX and you need to perform a System Restore. So I'm going to try a virtualenv approach instead.This SO question attempts to replace the sqlite3 library linked in a
virtualenv
but I haven't figured out how to apply this to SQLAlchemy How to upgrade sqlite3 in python 2.7.3 inside a virtualenv?