[Pythonmac-SIG] SQLite & python

Dethe Elza delza at livingcode.org
Tue Mar 28 21:52:12 CEST 2006


On 3/28/06, Dan Grassi <dgrassi at lexar.com> wrote:
> Hi,
>
> I am totally confused by all the versions and name conflicts of py-
> sqlite and sqlite not to mention the python version confusion.  What
> I really want to do is use both sqlite version 2 and sqlite version 3
> since I have existing sqlite version2 DBs and new CoreData apps that
> use sqlite version 3.  From a version/nomenclature standpoint there
> is a huge mess eg: py-sqlite works with either sqlite 2 or sqlite 3
> and py-sqlite2 works with sqlite version 3.
>
> I have been using py-sqlite with sqlite version 2 successfully.
>
> First problem I see is that there are two version of Python  on my
> Tiger system:
> /usr/bin/python version 2.3.5

The above is Apple-supplied Python.  Apple uses it for internal
scripting stuff, you should pretend it isn't there.  Ignore it, don't
use it, but whatever you do, don't try to remove or replace it.

> /usr/local/bin/python version 2.4.1

This is the one you want.  If your shell doesn't already point to this
by default when you type "python" on the command line, it should.  Try
"which python" to see what your default is.

> Second problem:
> The (Apple) installed version of sqlite3 is 3.0.8.6
> py-sqlite 2.1 requires sqlite 3.2.2
> py-sqlite 2.0 requires sqlite 3.1
> py-sqlite 1.1 requires sqlite 3.x
> So it seems that py-sqlite 1.1 is the one I need.

To complicate matters, there is also APSW (Another Python SQLite
Wrapper) which can be used with any version of SQLite.

http://www.rogerbinns.com/apsw.html

> If I install it my installed py-sqlite that used the python sqlite
> version 2 gets overwritten, not nice.  It also seems to get
> instaslled in the python 2.3 library, also not nice.

Probably your PATH environment variable points to the Apple-installed
python before the current python.  You can change this, probably in
the ".bash-profile" file in your home directory.  Make sure
/usr/local/bin comes before /usr/bin in the PATH.

> If I go to darwin ports it wants to upgrade my python to 2.4.2 first.

Why do you need DarwinPorts?  You have both Python and SQLite
installed already.  Just download the wrapper (pysqlite or apsw) and
install it using "python setup.py build; sudo python setup.py install"
 after making sure the correct python is in your PATH.

> Does anyone have a solution?

See above.

> All in all the whole Python database (lack of) mess is ridiculous!  I
> know that Guido does not feel that databases have any place in python
> but I don't get it, why does the "batteries included" not include
> database support, databases like MySQL, PostgreSQL & SQLite?

Python's batteries do include BerkelyDB "out of the box", as well as
gdbm and/or dbm, including a built-in portable implementation of dbm
for platforms that don't have it already.  There are wrappers for
PostgreSQL, MySQL, Oracle, SQLite, etc. There are object-relational
mappings like SQLObject. The python world has a very rich and lively
database environment.

> At this point I am ready to mostly give up on Python after over 10
> years of use and evangelizing.

That would be too bad.  It's just getting really good.

--Dethe


More information about the Pythonmac-SIG mailing list