Question re: cursorField using MySQLdb

chibaA at TinterlogD.Tcom chibaA at TinterlogD.Tcom
Wed May 10 18:55:05 EDT 2000


I'm having a bit of difficulty trying to figure out how I can
determine the column-type for a piece of data.  Here's an abbreviated
snippet of code:

01 for cursorRecord in resultSet:
02        print "<tr>\n"
03        for cursorField in cursorRecord:
04                if key == 'email_address':
05                        print "<td><a href=mailto:\"" + value +
"\"><font face=verdana size=2>" + value + "</font></a>"
06                else:
07                        print "<td><font face=verdana
size=2>"+cursorField+"</font></td>"

Line 4 is the main culprit.  I've placed "key" in there for now - but
that's not what I need.  

Basic scenario - it's reading a line out of the table, with various
pieces of data - like names, addresses, etc.  With email_address, I'd
like to be able to add a <a href="mailto:email_address"> job into it -
but I don't know how to address that specific piece of data.

(.. maybe read the pseudo-code below, before you continue...)

Sorry this is so confusing.  In the part before this, each of the
cursorFieldNames & cursorDescriptions are read in (which correspond to
the column names, such as name, email_address, etc.).  But I have no
access to these labels when processing the cursorField, and
cursorRecord fields.

In pseudo-code, this is what I want to accomplish:

- read in the column names & print them out in a table (DONE)
- read in the fields row by row, AND treat each field of each column
differently when placing it in the table

	ie. fields under the names column might be linked somewhere;
	fields under email_address might be linked to their email,
etc.

Anyone have any ideas?  (it's probably a 2 second answer!)
Additionally, I can't seem to get any specific information about
commands for MySQLdb (maybe even with examples)... any ideas on where
I could find some?

Thanks.

kc



More information about the Python-list mailing list