Replace one element of a tuple (LONG)

Brian almondb at gmail.com
Thu Jun 1 18:53:37 EDT 2006


Captain Dondo wrote:
> What I'd like to do is build the correct selectlist in the first place,
> rather than build the wrong one and then rebuild a correct one.

This is sounding more like a SQL/DB problem and less like a Python one.
 If you have a field that is being pulled from the database that you
would like to do a substitution on, I'm fairly sure MySQL includes a
CASE statement in their flavor of SQL.  Instead of performing a  SELECT
* in your script you could select the individual fields you want, and
instead of just pulling the problematic column as is, you could pull it
as something like "select case when sourcehost = x then y else
sourcehost end case, ...".  Naturally if an entire column needs to be
replaced with a static value, you won't even need to use CASE.

HTH




More information about the Python-list mailing list