Python

The default way is to replace the pre-installed SQLite library with the one we compiled containing the LiteSync.


Linux

The Python's sqlite3 module interfaces with the installed libsqlite3.so.0

We can check it using the command bellow:

ldd /usr/lib/python2.7/lib-dynload/_sqlite3.so


1. Get LiteSync

You can either compile it or use pre-compiled binaries. You can request them by e-mail for testing purposes.

It should be installed on the /usr/lib folder.


2. Install it for Python

We have 3 options to make Python use the modified SQLite library containing LiteSync:


A. Use the LD_LIBRARY_PATH when opening python

LD_LIBRARY_PATH=/usr/lib python app.py

B. Overwrite the pre-installed library

cd /usr/lib/arm-linux-gnueabihf  (or x86_64-linux-gnu, it depends on the architecture)

ln -sf /usr/lib/libsqlite3.so.0 libsqlite3.so.0

C. Set the rpath in the wrapper library

For this we need patchelf:

git clone https://github.com/NixOS/patchelf

cd patchelf

./bootstrap.sh

./configure

make

sudo make install

To set the rpath in the wrapper library:

patchelf --set-rpath /usr/lib /usr/lib/python2.7/lib-dynload/_sqlite3.so

To check if it was successful:

objdump -p /usr/lib/python2.7/lib-dynload/_sqlite3.so | grep RPATH


Windows

Replace the file sqlite3.dll in the folder \Python\DLLs with the one containing LiteSync.


Usage

Then we can use the sqlite3 module normally, passing a URI in the place of the filename.

Example code:

import sqlite3

conn = sqlite3.connect('file:data.db?node=secondary&connect=tcp://server:port')