Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43133
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'lines,': 0.07; 'postpone': 0.07; 'orm': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'span': 0.09; 'api': 0.11; 'stored': 0.12; '(object': 0.16; 'kern': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:sub': 0.16; 'tables,': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'later': 0.20; 'example': 0.22; 'header:User- Agent:1': 0.23; 'interpret': 0.24; 'lets': 0.24; 'login': 0.25; 'sort': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'robert': 0.30; 'along': 0.30; "i'm": 0.30; 'code': 0.31; 'relational': 0.31; 'work:': 0.31; 'class': 0.32; 'probably': 0.32; 'figure': 0.32; 'device': 0.34; 'basic': 0.35; 'classes': 0.35; 'connection': 0.35; 'but': 0.35; 'really': 0.36; 'accessing': 0.36; 'oracle': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'throughout': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'skip:n 30': 0.60; 'our': 0.64; 'different': 0.65; 'world': 0.66; 'believe': 0.68; 'eco': 0.84; 'received:125': 0.84; 'terrible': 0.84; 'url:sqlalchemy': 0.84; 'device.': 0.93; 'imagine': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Robert Kern <robert.kern@gmail.com> |
| Subject | Re: classes and sub classes? |
| Date | Tue, 09 Apr 2013 13:15:42 +0530 |
| References | <CACQBTrROkAUTNdNbb=Mjg3HBs2koEaZcOCz=417BQFO=7NEhFQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 125.21.252.133 |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
| In-Reply-To | <CACQBTrROkAUTNdNbb=Mjg3HBs2koEaZcOCz=417BQFO=7NEhFQ@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.325.1365493556.3114.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1365493556 news.xs4all.nl 6931 [2001:888:2000:d::a6]:38205 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:43133 |
Show key headers only | View raw
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: classes and sub classes? Robert Kern <robert.kern@gmail.com> - 2013-04-09 13:15 +0530
csiph-web