MySQLdb and column names

beef winterbeef at gmail.com
Wed Jan 30 18:04:26 CET 2008


Hello all,

I am using MySQLdb 1.2.2 and have a question about the construction of
the dictionary keys of a result set.

Here is an example query, from which you may intuit some of the
structure of the tables:

SELECT
  shots.*,
  users.*,
  sequences.*,
  jobs.*
FROM
  shots
LEFT JOIN
  users ON  users.id=shots.user_id
INNER JOIN
	sequences ON sequences.id=shots.sequence_id
INNER JOIN
	jobs AS j ON j.id=sequences.job_id
WHERE
	shots.id=%s

1. The 'users' table has a column named 'id', as do all the other
tables.
2. I define my cursor as a 'DictCursor' so that my results are
dictionaries
3. The 'shots' id has the key name of 'id', while all the -other-
'id's have key names of the form: "<TABLE>.id"

I would prefer to have the key names consistent, so that event the
"shots" fields have key names of the form  "<TABLE>.id"

Is this possible?

Thanks in advance!

--
Wellington




More information about the Python-list mailing list