portable non-relational database
Asked Answered
S

9

2

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.

Smatter answered 22/2, 2009 at 16:31 Comment(3)
@hansen j: Are you currently using an ORM layer? If so, which one?Normi
"portable, meaning it doesn't require an installation. " Sorry, I don't think there is anything that doesn't require installation.Lilongwe
"Installation" as in separate server process is a much bigger deal than "must have certain Python libs".Horme
H
7

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.

Horme answered 23/2, 2009 at 4:49 Comment(1)
I love the license caveat. They are always critical for me when making a decision...Luckin
P
5

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).

Paquito answered 23/2, 2009 at 3:1 Comment(0)
H
4

BerkleyDB

Handgun answered 22/2, 2009 at 16:35 Comment(0)
T
4

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.

Thermel answered 22/2, 2009 at 16:43 Comment(3)
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!Smatter
@Smatter 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.Normi
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);Thermel
E
3

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.

Epi answered 22/2, 2009 at 16:41 Comment(4)
There's a beta version of a binary installer for windows available here: wiki.apache.org/couchdb/Windows_binary_installer I've only run it on OS X and Linux though.Epi
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?Flaunty
heavy install the extreme opposite of portable :(Smatter
We seem to have different definitions of portable, I should have read your question more closely.Epi
R
2

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

Roselinerosella answered 22/2, 2009 at 16:35 Comment(2)
BDB bindings are in the standard library, actually, used by shelve, anydbm and others.Tacheometer
Unfortunately the standard library bindings are depreciated in Python 2.6 and removed in Python 3.0Franciscka
P
1

Adding a reference to TinyDB here since this page is showing at the top of many searches. It is a portable non-relational database in python. It stores python dicts into a local json file and makes them available for database ops similar to mongodb. It also has an extension to port to mongodb's commands, the difference being that instead of working on another system server you'll be operating on a local json file.

And unlike the presently chosen answer, it is under a permissive MIT open license.

Links:

Partisan answered 25/3, 2018 at 2:28 Comment(0)
N
0

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.

Normi answered 22/2, 2009 at 17:43 Comment(4)
I am using django, it's just that every time I change the model, I have to go and change the database!Smatter
I just saw your comment on the Pate's answer. Could you clarify how does SQLite make schema management transparent?Smatter
@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.Normi
ok, so sqlalchemy + sqllite make a portable database that's practically schema-free?Smatter
P
0

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.

Pappose answered 23/2, 2009 at 3:52 Comment(1)
shelve pickles objects to a bsddb (Berkeley), so if you need simple persistence, this might be a solution.Tacheometer

© 2022 - 2024 — McMap. All rights reserved.