[BioSQL-l] Python ORM mapping for BioSQL

Nick Loman n.j.loman at bham.ac.uk
Fri Nov 28 15:59:53 UTC 2008


Peter wrote:

>> However, the version of Django I use (not sure about latest) didn't support
>> multi-column indexes as primary key, so I had to add another auto_increment
>> column to use as a primary key.
> 
> When I started looking at web-frameworks and ORM, I didn't want to
> modify a perfectly good schema (BioSQL) just to cope with a limited
> tool.

Fair enough.

> I investigated Django earlier this month, and rejected it because it
> doesn't yet support multi-column indices as primary keys.  They've had
> an open bug on this for 3 years, with no expected date yet:
> http://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys
> http://code.djangoproject.com/ticket/373
> 
> My impression is that Django's philosophy is that they expect you to
> define your objects which then automatically defines the database
> schema.  Note the title of this FAQ page refers to an existing schema
> as a "legacy" database:
> http://docs.djangoproject.com/en/dev/howto/legacy-databases/
> If Django can cope with an existing schema, then it does look like an
> excellent package, and seems well documented.

You can still use Django even if you don't want to modify your database, 
with the caveat that certain functions (e.g. adding a new taxon via the 
ORM) will not work correctly. If you are just querying data that still 
might be sufficiently useful.

And Django will let you fall back to raw SQL if you should need to at 
any point.

I personally was extremely skeptical about an ORM because of the added 
level of complexity, and sometimes difficulty understanding the 
relationship between the generated models and the underlying database. 
However, Django (like Python's) basic principles of DRY and "don't do 
anything magic" mean that I find the results acceptable enough for my 
applications.

I wouldn't make an argument to change BioSQL to suit Django, but I would 
commend Django to anyone using Python who wants an ORM - particularly if 
they are building a dynamic web site!

Cheers,

Nick.




More information about the BioSQL-l mailing list