Out of the box database support

Paul McGuire ptmcg at austin.rr._bogus_.com
Mon Jul 3 12:48:11 EDT 2006


"Alex Biddle" <heuristic at gmail.com> wrote in message
news:mailman.7731.1151943001.27775.python-list at python.org...
> Hey, thanks for the reply Jean-Paul.
>
> That's pretty cool knowing that Python 2.5 will have it out of the
> box, however what about basic out-of-the-box functionality in 2.4 (or
> even older)?
>
> In all my other experiences Python comes with a lot of tools already
> available, it seems odd not to have basic database functionality
> installed as default.
>

Would you like a pony with that?  pysqlite *is* available today, and is not
overly onerous to install or bundle with your own package.  And on the near
horizon, we see that it *will* be part of the included batteries, so
separate installation is only a temporary nuisance.

But there is another database battery available in current Python versions.
Try this:

import bsddb


No SQL support, instead this gives you a dict-like access to the database
(values must be strings, so you have to serialize columns into something
like XML, JSON, YAML, etc.):

import bsddb
db = bsddb.hashopen("testdb.db")
db["Paul"]="""<user name="Paul" id="12345"/>"""
db["Alex"]="""<user name="Alex" id="12346"/>"""
print db.keys()
del db["Paul"]
print db.keys()
db.close()


-- Paul





More information about the Python-list mailing list