[orm-devel] Re: ORM

Diedrich Vorberg orm-devel@mailman.tux4web.de
Fri, 6 Dec 2002 11:09:08 +0100


Hi Uwe,

for a moment I though you to be Austrian, with that German name and 
all. But after checking I figured you're not only across the Alps but 
even Down Under... 

>My questions are
>	Does orm handle table inheritance?
Well... not really. What I usually do is this:

class base(dbclass):
      columns = {"id": serial(),
                 "name": varchar()}

class child(base):
      columns = base.column.copy().update({ "surname": varchar(),
                                            "age": integer() })
      

This way the Python classes have a parent/child relationship as the 
tables do. Unfortunately you'll have to take care of the child having 
the right clumns by hand.

Note that it is essential to use base.columns.copy(), because 
otherwise you'll modify base's column dics as well!

>	What are the performance and memory penalties for using orm?
Minimal I'd suppose. See, ORM is rather simple in nature, (actually 
that's the point in it :-) and things you do to your dbObjects will 
translate to SQL commands directly. There is a certain overhead of 
function calls, of course. An asignment will call

  dbobj.__setattr__
  (the column class') set()
  (the datasource's) update()
  (the datatype's) format()
  (with the commit() or flushUpdates()) datasource.execute()

And some more I don't know by heart. But there are no expensive
computations involved, really.

>	Can orm be used to create the tables based on the column defs?
No. Mike Watkins sent a program in that goes the other way 'round and
creates orm's class definitions from the SQL layout. Check the 
contrib/ directory.

>	Do all the table classes need to be imported at once or can 
>	  we do "from beans import person, address"?
This import statement will work as expected.

>Sorry if my questions appear silly. I'm new to Python and to SQL. I have
>been developing accounting systems for 22 years using 4GL's and this
>will be my last one so any assistance or advice would be greatly
>appreciated.
There's no such thing as a silly question, just silly answers. You 
have nearly as much programming experience as I am old ;-) If there 
is any advise or suggestions from your side, I'm eager to hear them! 
BTW: what are 4GL's?

>Uwe Feldtmann.
Diedrich

-- 
           _..._                            Diedrich Vorberg
         .'     '.
        /  _   _  \                         http://www.tux4web.de
        | (o)_(o) |                         info@tux4web.de
         \(     ) /            .---.
         //'._.'\ \           /     \       Internet Dienstleistungen
        //   .   \ \          \.@-@./       und 'Consulting'.
       ||   .     \ \         /`\_/`\
       |\   :     / |        //  _  \\      Linux Rules!
       \ `) '   (`  /_      | \     )|_
     _)``".____,.'"` (_    /`\_`>  <_/ \
     )     )'--'(     (    \__/'---'\__/
      '---`      `---`