views:

157

answers:

4

I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that:

  1. Creates a database table from a simple type description (int, float, datetime etc)
  2. Takes a dictionary object and inserts it into the database (including handling datetime objects!)
  3. If possible: Can handle basic references, so the dictionary can reference other tables

I would prefer something that doesn't do a lot of magic. I just need an easy way to setup and get data into an SQL database.

What would you suggest? There seems to be a lot of ORM software around, but I find it hard to evaluate them.

A: 

Seeing as you have mentioned sql, python and orm in your tags, are you looking for Django? Of all the web frameworks I've tried, I like this one the best. You'd be looking at models, specifically. This could be too fancy for your needs, perhaps, but that shouldn't stop you looking at the code of Django itself and learning from it.

Ninefingers
No one said anything about "web".
Ignacio Vazquez-Abrams
Django is nice, but it's not what I need for this project.
pehrs
@Ignacio True, true, the two seem to go together quite often. I like the look of SQLAlchemy that @muckabout mentioned below.
Ninefingers
+4  A: 

SQLAlchemy's SQL expression layer can easily cover the first two requirements. If you also want reference handling then you'll need to use the ORM, but this might fail your lightweight requirement depending on your definition of lightweight.

Ants Aasma
SQLAlchemy seems like it will suit me just fine for this project. Thanks for the help!
pehrs
+2  A: 

SQLAlchemy offers an ORM much like django, but does not require that you work within a web framework.

muckabout
+1  A: 

From it's description, perhaps Axiom is a pythonic tool for this .

CaseyIT
Axiom looks very interesting, but the limitation to SQLight breaks it for me. I need something that can handle atleast MySQL an preferably also Postgresql on the backend side.
pehrs