Django Vs Rails

Greg McIntyre greg at puyo.cjb.net
Wed Sep 7 20:01:39 EDT 2005


Diez B. Roggisch wrote:
> I tried to find out if subway and
> rails can do the same - that is, generate the sql. For subway the lack
> of documentation prevented that, and I didn't find it in rails , too.

In Rails you can do that with the command:

$ rake db_structure_dump

However I think it's not the prescribed way of using it because it
tends to involve losing all your data every time you make a schema
change. I think they recommend doing this once at the start of
development if you don't have a DB schema yet. Once you're up and
running, if you rely on ALTER TABLE type commands and manually update
your code to match the new schema, although it's more work it leaves
your data intact. I think that's the idea anyway.


> And there is at least one shortcoming to the first approach, when using
> the most popular RDBMS, MySQL: The lack of foreign key constraints makes
> me wonder how to automatically infer 1:n or m:n relationships. From a
> rails tutorial, I see that one has to declare these too:
>
> http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=5
>
>
> But maybe someone who has expirience with subway or rails can elaborate
> on this?

>From my experience with Rails, the OR mapping isn't hugely automated.
That is, some manual work is required if you change the schema, to
update the code that operates upon it. However although this is another
step it is pretty trivial due to the metaprogramming style methods.
Besides, if you're altering the schema you tend to have to update some
code anyway as you're most likely altering the functionality of the
system a little. And as I said above, a loose/manual OR mapping has its
benefits; I don't feel anxious about losing my data/schema when using
Rails because I know it leaves it alone.




More information about the Python-list mailing list