views:

755

answers:

8

I want to experiment/play around with non-relational databases, it'd be best if the solution was:

  • portable, meaning it doesn't require an installation. ideally just copy-pasting the directory to someplace would make it work. I don't mind if it requires editing some configuration files or running a configuration tool for first time usage.
  • accessible from python
  • works on both windows and linux

What can you recommend for me?

Essentially, I would like to be able to install this system on a shared linux server where I have little user privileges.

+4  A: 

BerkleyDB

tliff
+2  A: 

BerkeleyDB : (it seems that there is an API binding to python : http://www.jcea.es/programacion/pybsddb.htm)

Pierre
BDB bindings are in the standard library, actually, used by shelve, anydbm and others.
Gregg Lind
Unfortunately the standard library bindings are depreciated in Python 2.6 and removed in Python 3.0
Ian G
+3  A: 

Have you looked at CouchDB? It's non-relational, data can be migrated with relative ease and it has a Python API in the form of couchdb-python. It does have some fairly unusual dependencies in the form of Spidermonkey and Erlang though.

As for pure python solutions, I don't know how far along PyDBLite has come but it might be worth checking out nonetheless.

Hank
crouchDB's description sounds very good, but is it portable?
hasen j
There's a beta version of a binary installer for windows available here: http://wiki.apache.org/couchdb/Windows_binary_installerI've only run it on OS X and Linux though.
Hank
I would not say it is particularly portable at this stage. Depends what you mean by portable I guess. Would you consider Mysql and Postgresql portable given the number of operating systems it runs on, but is a heavy install?
Evan
heavy install the extreme opposite of portable :(
hasen j
We seem to have different definitions of portable, I should have read your question more closely.
Hank
+3  A: 

If you're used to thinking a relational database has to be huge and heavy like PostgreSQL or MySQL, then you'll be pleasantly surprised by SQLite.

It is relational, very small, uses a single file, has Python bindings, requires no extra priviledges, and works on Linux, Windows, and many other platforms.

Roger Pate
I want it to be schema-free, so I can change the models in my code without running sql commands. sql-lite sounds perfect, but it's relational!
hasen j
@hasen j: you can easily manage your schema from within your application -- you don't need professional DBA's to do that. If you use SQLAlchemy, you schema management is almost transparent to your app.
S.Lott
If you really just want name-value pairs with a dead simple schema.. you can do that in SQLite, while still getting its ease, portability, locking, transactions, etc.: CREATE TABLE simple (id INTEGER PRIMARY KEY, name UNIQUE, value); CREATE INDEX idx_simple_name ON simple(name);
Roger Pate
A: 

Have you looked at Zope Object Database?

Also, SQLAlchemy or Django's ORM layer makes schema management over SQLite almost transparent.


Edit

Start with http://www.sqlalchemy.org/docs/05/ormtutorial.html#define-and-create-a-table to see how to create SQL tables and how they map to Python objects.

While your question is vague, your comments seem to indicate that you might want to define the Python objects first, get those to work, then map them to relational schema objects via SQLAlchemy.

S.Lott
I _am_ using django, it's just that every time I change the model, I have to go and change the database!
hasen j
I just saw your comment on the Pate's answer. Could you clarify how does SQLite make schema management transparent?
hasen j
@hansen j: "If you use SQLAlchemy, you schema management is almost transparent to your app" is what I said. Not SQLite, but SQLAlchemy ORM over SQLite. But if you're using Django, you'll have the same set of problems. Please update your question with the Django fact.
S.Lott
ok, so sqlalchemy + sqllite make a portable database that's practically schema-free?
hasen j
+4  A: 

Metakit is an interesting non-relational embedded database that supports Python.

Installation requires just copying a single shared library and .py file. It works on Windows, Linux and Mac and is open-source (MIT licensed).

dF
+1. Metakit is cool. Too bad it is too old.
muhuk
+1. Agree with muhuk...
torial
A: 

If you're only coming and going from Python you might think about using Pickle to serialize the objects. Not going to work if you're looking to use other tools to access the same data of course. It's built into python, so you shouldn't have any privileged problems, but it's not a true database so it may not suit the needs of your experiment.

acrosman
shelve pickles objects to a bsddb (Berkeley), so if you need simple persistence, this might be a solution.
Gregg Lind
+6  A: 

I recommend you consider BerkelyDB with awareness of the licensing issues.

I am getting very tired of people recommending BerkleyDB without qualification - you can only distribute BDB systems under GPL or some unknown and not publicly visible licensing fee from Oracle.

For "local" playing around where it is not in use by external parties, it's probably a good idea. Just be aware that there is a license waiting to bite you.

This is also a reminder that it is a good idea when asking for technology recommendations to say whether or not GPL is acceptable.

From my own question about a portable C API database, whilst a range of other products were suggested, none of the embedded ones have Python bindings.

Andy Dent
I love the license caveat. They are _always_ critical for me when making a decision...
torial