Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43133 > unrolled thread

Re: classes and sub classes?

Started byRobert Kern <robert.kern@gmail.com>
First post2013-04-09 13:15 +0530
Last post2013-04-09 13:15 +0530
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: classes and sub classes? Robert Kern <robert.kern@gmail.com> - 2013-04-09 13:15 +0530

#43133 — Re: classes and sub classes?

FromRobert Kern <robert.kern@gmail.com>
Date2013-04-09 13:15 +0530
SubjectRe: classes and sub classes?
Message-ID<mailman.325.1365493556.3114.python-list@python.org>
On 2013-04-09 11:20, Morten Guldager wrote:
> 'Aloha Friends!
>
> I'm about to write an API against a huge propitiatory Oracle based network
> inventory database. The database have many different concepts stored in it's
> tables, can one concept can span over multiple tables.
>
> I would like to write a class for accessing each concept, but only have a single
> database connection throughout the whole program.
>
> I imagine some code along these lines, but cant figure out how to declare the
> classes that will make it work:
>
> # create a connection to the database and perform come basic login and
> initialization
> nib = NwInvDb("scott/tiger@ora")
> # find a device by ip
> interesting_device = nib.Device.lookup_by_ip("192.168.1.1")
>
> In this example I access the concept Device.
>
> Should I make the Device class inherit from NwInvDb? Or should I keep them
> separate? Later on I think I will even have to make some sort of sub-concepts,
> but lets postpone that game until I really have really seen the need!

You probably want to use an off-the-shelf ORM (Object Relational Mapper) instead 
of writing your own ad hoc ORM.

   http://www.sqlalchemy.org/

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web