[Zope] Howto convert ZSQL results

Casey Duncan c.duncan@nlada.org
Fri, 2 Nov 2001 12:02:22 -0500


On Friday 02 November 2001 11:21 am, Julián Muñoz Domínguez allegedly wrote:
> How to convert to integer the the result of a ZSLQ method  ??
>
>
>
>
> I call a ZSQL method with:
> l=int(container.last_customer())
>
>
> The field I query is has the type "VARCHAR(10) with Null"
> I am doing this query through ZODBC DA, to an Access .mdb file.
>
> I am digging many hours in the Documentation, and doesn't find the answer.
>
>
> I get this error:
>
>
> Zope Error
>
>              Zope has encountered an error while publishing this resource.
>
>              Error Type: AttributeError
>              Error Value: DatabaseResults instance has no attribute
> '__int__'
>

It sounds like you are trying to convert the whole row or recordset to an 
int, which obviously won't work. You need to return just the field by itself 
like:

I=int(container.last_customer().name_of_field)

or possibly:

I=int(container.last_customer()[0].name_of_field)

hth,
/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/