Python choice of database

Oren Tirosh oren.tirosh at gmail.com
Mon Jun 20 14:43:28 EDT 2005


Philippe C. Martin wrote:
> Hi,
>
> I am looking for a stand-alone (not client/server) database solution for
> Python.
>
> 1) speed is not an issue
> 2) I wish to store less than 5000 records
> 3) each record should not be larger than 16K

How about using the filesystem as a database? For the number of records
you describe it may work surprisingly well. A bonus is that the
database is easy to manage manually. One tricky point is updating: you
probably want to create a temporary file and then use os.rename to
replace a record in one atomic operation.

For very short keys and record (e.g. email addresses) you can use
symbolic links instead of files. The advantage is that you have a
single system call (readlink) to retrieve the contents of a link. No
need to open, read and close.

This works only on posix systems, of course. The actual performance
depends on your filesystem but on linux and BSDs I find that
performance easily rivals that of berkeleydb and initialization time is
much faster. This "database" also supports reliable concurrent access
by multiple threads or processes.

See http://www.tothink.com/python/linkdb

Oren




More information about the Python-list mailing list