Pythonic ORM with support for composite primary/foreign keys?

  • Thread starter Wolfgang Keller
  • Start date
W

Wolfgang Keller

Hello,

so far it seems to me as if the only ORM module for Python which
supports composite primary/foreign keys was SQLAlchemy. Which looks a
little bit "overbloated" for my needs: I "just" need to be able to
define a "logical model" (à la UML) in Python and have the ORM connect
to a database (running on PostgreSQL in my case) which uses a
corresponding (pre-defined) "physical model" as its schema.

Modeling really does look exactly like what I need. Among others, it
seems to be understandable even for a Clueless Python Scripting
Dilettant like me. But support for primary keys is not yet completely
built-in (and tested).

So, is there another ORM module for Python besides SQLAlchemy which
supports composite porimary (and foreign) keys, and maybe also other
more "advanced", maybe even some of the PostgreSQL-specific features
(such as e.g. composite types)?

TIA,

Sincerely,

Wolfgang Keller
 
M

Marco Mariani

Wolfgang said:
so far it seems to me as if the only ORM module for Python which
supports composite primary/foreign keys was SQLAlchemy. Which looks a
little bit "overbloated" for my needs: I "just" need to be able to
define a "logical model" (à la UML) in Python and have the ORM connect
to a database (running on PostgreSQL in my case) which uses a
corresponding (pre-defined) "physical model" as its schema.

I think if your model is complex enough that you need composite foreign
keys, the project might deserve SQLAlchemy.

Mapping a bunch of python classes to an efficient DBMS schema is not
easy by any definition of "easy".

Google for "orm vietnam"... it might also be useful to read "The Art of
SQL" even if you don't plan to write SQL by hand.
 
J

Jeff

Django has a wonderful ORM that can be used separately from the
framework, but it is pretty top-heavy as well. I'm afraid that size
is the price you pay for abstraction. Your business logic code
shrinks, but the supporting libraries grow.
 
J

jay graves

Django has a wonderful ORM that can be used separately from the
framework, but it is pretty top-heavy as well. I'm afraid that size
is the price you pay for abstraction. Your business logic code
shrinks, but the supporting libraries grow.

But the OP specifically asked for composite keys, which Django's ORM
does not support.

....
Jay
 
J

Jonathan LaCour

jay said:
But the OP specifically asked for composite keys, which Django's ORM
does not support.

SQLAlchemy is the way to go, for his use case. If he wants a
more concise and easier to use syntax, he can install Elixir
(http://elixir.ematia.de), which makes things look a bit more familiar.

Elixir does support composite primary keys.
 
W

Wolfgang Keller

Hello,

thanks for the hints towards Elixir and Storm.

In fact I would have loved to use Modeling
(http://modeling.sourceforge.net/), as it seems to fulfil all my
requirements perfectly so far, except the one with the composite keys.
In particular I like its proximity to EOF (R.I.P.) concerning the basic
concepts and the notification service. I would like the notification
service even more if it was possible to send notifications directly
from PostgreSQL. ;-) Well, maybe that would even be possible using
PL/Python... :-?

Modeling imho is especially well documented and at a first glance the
sourcecode seems to be quite comprehensible even to me (unlike
SQLAlchemy :-( ). The author has stated that composite keys were
foreseen to be implemented and that the code was already written
considering this feature.

So I'll maybe even try to "hack" it until it works for my schema, with
(hopefully) some spoonfeeding by the original author. But in case my
skills aren't enough to actually make it work, I need a fallback
option.

Maybe someone could even convince someone else >;-> to implement a
"plug-in" for Gaphor (or for MetaEdit) for Modeling, so that one could
generate (and round-trip) nice "colorful and children-suitable"
diagrams for the CXOs... >:->

TIA,

Sincerely,

Wolfgang Keller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top