Kent Johnson wrote on 08.08.2005:

>Jan Eden wrote:

>>The documentation for MySQLdb says that fetchoneDict() is
>>deprecated and the usage of fetchone() is suggested.
>
>You could just use fetchoneDict(); deprecated isn't the same as
>gone...

I tend to avoid deprecated functions/methods - I would need another method 
sooner or later anyway.
>>
>>Is there a recommended way to receive the results of an SQL query
>>in the form I need? Or do I have to create a dictionary of
>>fieldname tuples which can be zipped with the query result tuple?
>
>You can create a list of field names from the cursor.description
>attribute. But if the number of fields in the result varies how do
>you know which field goes with which description?
>
That works, thank you. I will use the cursor.description attribute immediately 
after executing a query, so it will contain the correct field descriptions 
whenever I need them. The rest of my program uses the type attribute to decide 
which fields are present and which are not.

All this is part of a port from Perl to Python - I will publish a log of 
everything I encountered in a couple of weeks.

Cheers,

Jan
-- 
There's no place like ~/
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to