On 4/10/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote: > > On 4/10/06, George Sakkis <[EMAIL PROTECTED]> wrote: > > I understand Django doesn't support database views > > (http://en.wikipedia.org/wiki/View_%28database%29) right out of the > > box, but I was wondering if there's a reasonably easy way to implement > > (or at least emulate) them. Here's an illustration of a possible API > > (compatible to the magic-removal DB API): > > Hi George, > > I seem to recall using Django with database views in the past. Django > models are simply wrappers around the database, so it should work just > fine -- the only thing is, you can't make any changes to data > (assuming you're dealing with read-only views).
I researched this a bit and found that for MySQL-5.0, MS-SQL, and Oracle, you *can* update views that involve a join of multiple tables, with one limitation: You can't update multiple tables at the same time. Or to use the example, if you were updating PollChoice, you could not update values from Poll and values from Choice in the same UPDATE statement. However, since you are actually declaring what columns come from what tables in your View, it should be possible for the ORM to separate these into seperate statements. To otherwise update multiple tables in a view requires triggers and stored procedures. In PostgreSQL, it looks like you need a rule to even update one table of a view (or might only been needed for multiple table updates, I don't remember which). However, this should not be a limitation for the View class described above. -- The Pythonic Principle: Python works the way it does because if it didn't, it wouldn't be Python. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---