On Sep 19, 2006, at 10:44 AM, Diez B. Roggisch wrote:

>
> On Tuesday 19 September 2006 16:14, Tjaart de Beer wrote:
>> Hi
>>
>> I have scoured the web in search of an answer. Is there a way to  
>> create
>> your model.py file by reverse engineering an existing database? If
>> possible the code must be usable by SQLAlchemy.
>>
>> We are working with an existing database (+- 120 tables with 20-30
>> columns in each tables) and would like to connect and manipulate this
>> database from TG using SQLAlchemy. ANY ideas/suggestions are welcome!
>
> Frommy general experience with ORM: no, there isn't. Usually, a  
> hand-written
> schema is not as normalized as an ORM wishes, and even if it was,  
> some pesky
> details usually get in your way.
>
> You have several options:
>
>  - write a new model in SA, and a migration. However, that means  
> that no old
> code works anymore.
>
>  - try and map as much as possible using SA, tweaking it or at  
> least the model
> classes where necessary. But that is only a good idea if you come  
> as far as
> lest say 80 or even 90 percent because the old design is proper  
> (e.g. no
> compound keys and the like)

What's wrong with compound keys? SA has no problem with that.  SA's  
good at mapping all kinds of crazy stuff. I've even successfully  
mapped a table with no viable primary key (at SA's SQL layer) and  
then joined with another table to produce objects under SA's control.

>  - write you own model without any ORM at all, just using plain SQL  
> and some
> magic, for example attribute access.

This seems simple when you start down this path... eventually, you  
just end up with a less-useful ORM. I'd either go completely with an  
ORM or stick to SQL with access functions. Once you start making  
things try to look like objects, you're just writing your own ORM.

Kevin



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to