pysqlite

From DreamHost

Jump to: navigation, search

pysqlite is SQLite Bindings for Python for SQLite versions 2.8.x and 3.x (official wiki)

The instructions provided in this article or section require shell access unless otherwise stated.

You can use the PuTTY client on Windows, or SSH on UNIX and UNIX-like systems such as Linux or Mac OS X.
Your account must be configured for shell access in the Control Panel.
More information may be available on the article's talk page.

Contents

DreamHost Version

At 2007-03-09 DreamHost has sqlite 2.8.16 and sqlite3 3.2.1 installed.

$ sqlite3 -version
3.2.1
$ sqlite -version
2.8.16

pysqlite has three major versions (from pysqlite wiki):

  • 1.0.1 - the latest for SQLite 2.x databases and installed on DreamHost
>>> import sqlite
>>> sqlite.version
'1.0.1'
  • 1.1.x - compatibility version to allow old applications who uses SQLite 2.x database to run with SQLite 3.x
not installed
  • 2.x.x - optimized version for use with SQLite 3.x databases, 2.0.5 is currently installed on DreamHost
>>> from pysqlite2 import dbapi2
>>> dbapi2.version
'2.0.5'

Downloading

Version 1.1.8

wget http://initd.org/pub/software/pysqlite/releases/1.1/1.1.8/pysqlite-1.1.8.tar.gz
tar zxf pysqlite-1.1.8.tar.gz
cd pysqlite

Version 2.3.3

wget http://initd.org/pub/software/pysqlite/releases/2.3/2.3.3/pysqlite-2.3.3.tar.gz
tar zxf pysqlite-2.3.3.tar.gz
cd pysqlite-2.3.3

Configuring

Modify setup.py and change the include_dirs and library_dirs to where you installed the packages.

# change them to these two lines, changing USER to be your unix login
    include_dirs = ['/home/USER/include']
    library_dirs = ['/home/USER/lib']

Installation

~/bin/python setup.py build
~/bin/python setup.py install

Alternative instructions based on Unix account setup and a newer version of Python

Prerequisites

Select pysqlite Version

Depending on the version(s) of SQLite you have installed and the API you want to use, you may want to install pysqlite version 2.x (sqlite3, current API), pysqlite 1.1.x (sqlite3, legacy API), and/or pysqlite 1.0.x (sqlite2, legacy API), see [1].

You can install more than one version.

Put the version you chose in an environment variable ${VERSION}. Current (August 2007) versions are:

VERSION=2.3.5
VERSION=1.1.8a

or

VERSION=1.0.1

Now, generate variables to be able to use parts of the version number when downloading files:

VERSMINOR=${VERSION:0:5}
VERSMAJOR=${VERSION:0:3}
VERSINTEGER=${VERSION:0:1}


Download and Open pysqlite

mkdir -pv ${HOME}/soft
cd ${HOME}/soft
wget http://initd.org/pub/software/pysqlite/releases/${VERSMAJOR}/${VERSMINOR}/pysqlite-${VERSION}.tar.gz
tar xvzf pysqlite-${VERSION}.tar.gz
# 1.x versions open in an unversioned directory name, let's rename it
if [ ${VERSINTEGER} -lt 2 ]
then
  mv -v pysqlite pysqlite-${VERSION}
fi
cd pysqlite-${VERSION}

Configure

Tell the installer where to install pysqlite:

# For versions 1.x the environment variable ${LOCALBASE}
# holds the directory that will be used as a base
# for installing
LOCALBASE=${RUN}

cd ${HOME}/soft/pysqlite-${VERSION}

# For version 2.x you have to edit the new <code>setup.cfg</code>
if [ ${VERSINTEGER} -ge 2 ]
then
  mv -v setup.cfg setup-ORIG.cfg
  sed -r -e "s#^([ \t]*)include_dirs[ \t]*=.*#\1include_dirs=${RUN}/include#" \
         -e "s#^([ \t]*)library_dirs[ \t]*=.*#\1include_dirs=${RUN}/lib#" setup-ORIG.cfg \
      > setup.cfg
fi

Build and Install

python setup.py build
python setup.py install
Personal tools