Can I make sqlite3 or shelve work reliably on any Win/Linux/Mac?

Alex Quinn alexanderjquinn at
Mon Feb 22 18:10:38 CET 2010

Is there a way to have some kind of database (i.e. sqlite3, bsddb, dbm, etc.) that works out of the box on any Win/Linux/Mac machine with Python 2.6+ or 3.x? It's okay if the file format is different between machines, but I want my script to work without having to install anything.

Problems with current modules:

* Shelve used to do this.  Unfortunately, since bsddb was deprecated/removed from the standard distro and Windows doesn't have dbm or gdbm, the only remaining option on Windows is dumbdbm, which is discouraged in the docs.

* Sqlite3 should fill the void now.  However, in my experience, nearly every Linux Python install I encounter has a broken sqlite3 module ("ImportError: No module named _sqlite3"). It's a well-documented issue, but it the solution generally requires root access, which I don't have on these servers.

Potential solutions:

* Could I somehow bundle with my project the file and/or whatever else it needs? Or is there an alternate sqlite3 module I could use as a fallback that would just interface with the sqlite3 executable on the machine (i.e. /usr/local/bin/sqlite3)?

* Is there a way to drop bsddb into my project so it works out of the gate (no install) on either Linux, Windows, or Mac?

If you have any ideas, I'd be most appreciative.  My objective here is just to find a portable and reliable solution that I can use for small projects.



More information about the Python-list mailing list