SQL-Statement with Python

Steve Holden sholden at holdenweb.com
Tue Jan 16 18:43:37 EST 2001


"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:941jnd0634 at news1.newsguy.com...
> "Steve Holden" <sholden at holdenweb.com> wrote in message
> news:R2M86.5299$J76.42003 at e420r-atl1.usenetserver.com...
>     [snip]
> > > ActiveState distribution, but even if you started with the standard
> > > distribution you probably want to add win32all anyway if you work
> > > with Python under Windows... it has just too many nifty things!-).
> > >
> > I might take issue with this (despite my last run-in with the
> martellibot...
> > Perhaps I should just do this first [thwack, thwack, thwack]). There,
> that's
> > better.
>
> You dispute that one probably wants to add win32all if one works
> with Python under Windows...?!  *Eeeek*.  Let's see, where did I
> put the tar and feathers...
>
Certainly not. Hammond might be in Australia but he should know how I admire
and respect his work [scrape, scrape, grovel, grovel, take the pot off the
fire, please].
I intended to refer downwards (to the bit I took issue with) not upwards.
Honest.
>
> > > rows = recordset.GetRows()
> > > for first, last in zip(rows[0], rows[1]):
> > >     print "%s, %s" % (last, first)
> > >
> > That's the bit I don't like.  You call the GetRows method, and what does
> it
> > return? Columns, mate, that's what. At least to the Python user. Not
what
> I
> > call intuitive.
>
> Yeah, I agree on this detail -- two-dimensional arrays are always a
> bother to translate between languages which think the first index
> varies fastest (Fortran, Visual Basic, ...) and those which think
> it varies slowest (C/C++, Java, Python, ...).  GetRows was clearly
> written by somebody thinking of a language of the first ilk:-).
>
> Anyway, if that bothers you too much you get to choose among a
> zillion other ways to ask a recordset for its contents, e.g....:
>
> for row in recordset.GetString()[:-1].split('\r'):
>     first, last = row.split('\t')
>     print "%s, %s" % (last, first)
>
> Or, simpler and faster, one can show off one's command of 'advanced'
> SQL:-), and get the *db engine* to do one's work:
>
> recordset, result = connection.Execute(
>   "Select LastName//', '//FirstName From Employees Order By LastName")
> print recordset.GetString().replace('\r','\n')
>
pretty good, though I would suggest "... Order By LastName, FirstName" for a
definitive ordering. Wow, I wish my SQL was that good :-) And in fact I'm
one of those who tend to write SQL keywords in UPPER CASE because that's
what I'm used to.

>
> > I'm sure you'll have a great explanation for it, though.  Mark Hammond's
> was
> > pretty good.
>
> Explanation for _what_ 'it'?  I must be confused...
>
"It" being the row-major vs. column-major ordering. I had completely
overlooked the fact that Microsoft tend to design their subsystems to play
with *their* languages. Don't talk to me about world domination!

>
> Alex
>
regards
 Steve





More information about the Python-list mailing list