Database newbie - Sound Software Engineering practice for DB

Otto Tronarp otttr440 at student.liu.se
Sat Jan 25 06:44:56 EST 2003


On Wed, 2003-01-22 at 03:07, Justin Shaw wrote:
> It looks like you are on the right track.  Keep asking yourself these
> questions.  I have interjected my thoughts throughout.
> Justin
> 
> "Otto Tronarp" <otttr440 at student.liu.se> wrote in message
> news:mailman.1043194598.32555.python-list at python.org...
> > Hi,
> >
> > I'm a complete database newbie, the little I know I learned the last
> > couple of hours when browsing the web, and have a couple of questions on
> > what sound software engineering practice is when it comes to using
> > databases.
> >
[snip]

> >
> > But often I want different constraints on the query, like only matches
> > before a specific date or in a specific time period, etc. I could do a
> > getHomeMatchesBeforeDate(self, team, date),
> > getHomeMatchesForTimePeriod(self, team, start_date, end_date) but it is
> > pretty clumsy so I want something like getHomeMatches(self, team,
> > constraints), any ideas how I could implement that in a smooth way?
> 
> Make the common thing easy and the uncommon possible.  I do this by writing
> the common querries as you have with a couple of extra defaulted arguments:
> fields='*' and where='1'.  Then your query becomes something like
> 
> sql = 'select %s from TABLE where %s' % (fields, where)
> 
> I am working on a python/MySQL spelling application currently that three
> data layers and a GUI layer.  The data layers are:
> 1. database later (MySQL)
> 2. DB module -- class reprensentation of the database tables
> 3. SmartRow module -- class represention of the rows and relationships.
> 
> The application only interacts with the SmartRow module.  You can browse the
> csv on our sourceforge project if you want to have a look.
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/spellquest/spellquest/spellqu
> est/
> 

Thanks, that looks like a good example to study. Smal enough so I can
grasp it quickly and big enough so I actually learn something. I'll
definitely take a closer look at it.


> I've seen a few projects that are supposed to automatically write the
> interface to your db but I haven't tried the.  Check out the daily python
> url (linked on python.org), I think I saw them there.
> 
> Good luck and let me know if you have any good ideas for SpellQuest


Thanks for your comments.

Regards,
Otto






More information about the Python-list mailing list