4

This is a bit of a complex problem, at least for me. Here it goes:

I'm working as a user on linux server and it's safe to assume that installing any package not already installed is simply impossible.

Also I need to set up working Python 2.5 (not installed) with working SQLite3 library (Sqlite in any form not installed).

What I can do is: 1. Compile Python 2.5 and make it work 2. Compile amalgamation of SQLite3

Anyway - Python 2.5 is supposed to have interaction with Sqlite3 built-in (pysqlite). It seems true enough, however importing sqlite3: import sqlite3 fails because - in the end - it is impossible to import _sqlite3

Some googling lead me to understand that while pysqlite may be built-in, the sqlite is not. Therefore I assumed that I need to built in locally sqlite and somehow make these two pieces of software interact.

Fair enough.

I'm able to - I hope so - compile amalgamation to shared object but it seems messy. Should I rename sqlite3.so to _sqlite3 and throw it somewhere? It seems fishy a bit, I tried it anyway and get an error: dynamic module does not define init function (init_sqlite3)

At this point I'm a bit stuck. I'm not too familiar with building/compiling stuff - I admit that sudo apt-get / sudo yum made me lazy but for some reason it is not an option at the moment.

Help appreciated!

nimdil
  • 1,361
  • 10
  • 20

1 Answers1

6

First download, build and install sqlite3 with a --prefix. Then build python with same prefix , it will find sqlite installation and will build _sqlite3 module.

$ mkdir -p ~/applications/src
$ cd ~/applications/src
$ wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz
$ tar xvvf sqlite-autoconf-3070900.tar.gz
$ cd sqlite-autoconf-3070900
$ ./configure --prefix=~/applications
$ make
$ make install

$ cd ~/applications/src
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
$ tar xvvf Python-2.5.2.tgz
$ cd Python-2.5.2
$ ./configure --prefix=~/applications
$ make
$ make install

$ ~/applications/bin/python
>>> import sqlite3
>>> # no error!
Ski
  • 14,197
  • 3
  • 54
  • 64
  • 1
    Is there a way to replace just the _sqlite3 lib instead of having to rebuild an entire copy of python? I've got a case where I just want to "upgrade" my copy of sqlite a couple of revisions... – Mike Miller Nov 09 '12 at 22:24
  • I think we need to specify the path of sqlite header and library file for Python building although in some case the paths already existed in the default path config. http://stackoverflow.com/questions/26261080/compile-python-3-4-with-sqlite3 – http8086 Sep 09 '16 at 04:34