Skip to content

Building pysqlite with static env and savepoints

Laurence Rowe edited this page Mar 12, 2015 · 2 revisions

Include the following in your buildout:

[buildout]
versions = versions
parts = pysqlite

[versions]
pysqlite = 2.6.3-static-env-savepoints

[pysqlite]
recipe = zc.recipe.egg:custom
environment = pysqlite-env
find-links = https://github.com/lrowe/pysqlite/tarball/static-env-savepoints#egg=pysqlite-2.6.3-static-env-savepoints

[pysqlite-env]
STATICBUILD = true
SQLITE_AMALGAMATION_URL = http://sqlite.org/2013/sqlite-amalgamation-3071700.zip

To configure savepoint support for sqlalchemy using the included patch from https://code.google.com/p/pysqlite/issues/detail?id=24

from sqlalchemy import create_engine, event

engine = create_engine('sqlite:///')

@event.listens_for(engine, 'connect')
def connect(dbapi_connection, connection_record):
    dbapi_connection.operation_needs_transaction_callback = lambda x: True

And with zope.sqlalchemy

from zope.sqlalchemy.datamanager import NO_SAVEPOINT_SUPPORT
NO_SAVEPOINT_SUPPORT.remove('sqlite')
Clone this wiki locally