On Fri, 17 Dec 2004, Rene Bourgoin wrote:
> Ive been learning to interact with databases using python and i was > looking for ways to return a SELECT query result in a plain format. what > i mean by plain format is : > > name number address > Fred Smith 2125553243 1 main st > > All the pratices ive done return the results in tuples or tuples within > tuples. > (('fred smith','2125553243','1 main st')) > > I saw some examples on activestate that use the dbcp module Hi Rene, Ok, let's pause for a moment. I think I understand where all the confusion is coming from: it's a namespace issue, as well as a case of really really bad naming. You mentioned earlier that: > Yes i believe im looking for the python version of the Jakarta > database connection pool However, that is probably not what you're looking for. 'dbcp' in the context of the recipe that you've shown us: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81189 has nothing to do with connection pools! The author of that recipe has unfortunatetly named their module so as to make it easy to confuse it with the Apache Commons DBCP project: http://jakarta.apache.org/commons/dbcp/ But this is NOT the same 'dbcp' thing that the Python Cookbook recipe is talking about. The 'dbcp' Python Cookbook module refers to this snippet of code at the beginning of the recipe: ###### """This is dbcp.py, a module for printing out a cursor's output.""" def pp(cursor, data=None, rowlens=0): d = cursor.description if not d: return "#### NO RESULTS ###" names = [] lengths = [] rules = [] if not data: t = cursor.fetchall() for dd in d: # iterate over description l = dd[1] if not l: l = 12 # or default arg ... l = max(l, len(dd[0])) # handle long names names.append(dd[0]) lengths.append(l) for col in range(len(lengths)): if rowlens: rls = [len(str(row[col])) for row in data if row[col]] lengths[col] = max([lengths[col]]+rls) rules.append("-"*lengths[col]) format = " ".join(["%%-%ss" % l for l in lengths]) result = [format % tuple(names)] result.append(format % tuple(rules)) for row in data: result.append(format % row) return "\n".join(result) ###### So I think the confusion here is just more anecdotal support to how much a short, badly named variable name can damage a program. What bothers me is that the code in the recipe itself shows a disregard for good variable names. What the heck does 't', 'pp', 'dd', or 'l' stand for, anyway? *grin* _______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor