[Zope] SQL query result set - what data structure & how to access [(elements)]?

Lee lee.reilly@ntlworld.com
Sun, 21 Jan 2001 07:33:13 +0000


Hi,

I'm using a python method to query my database as follows, where I need
to use the result set to generate some HTML. I'm interested in result[0]
and result[1] as listed below;

* return result[0] gives me:
[{'name': 'PRACTICALS', 'type': 's', 'null': None, 'width': None},
{'name': 'TUTORIALS', 'type': 's', 'null': None, 'width': None},
{'name': 'ASSIGNMENTS', 'type': 's', 'null': None, 'width': None},
{'name': 'BONUS', 'type': 's', 'null': None, 'width': None}]

* return result[1] (or just 'return result') gives me:
[(1, 16, 9, 1)]

What kind of data structure is this? First impressions suggest that it's
a tuple but why the extra brackets?. I need to access each element but
how do I do this? I've tried all sort of tuple/list
conversions/operations and have had no success.

If the result is [(1, 16, 9, 1)] how can I assign...

a=1st element i.e. 1
b=2nd element i.e 16..?

I can convert it to a string, parse it and obtain the results that way,
which is simple enough, but surely there's a way to access the element
directly? Does anyone know?

Thanks,

Lee