Mailing List Archive

ZSQL + MySQL + sqltest + list
Hi,

Really frustrated by this.

<dtml-sqltest catId type=int multiple>

I want catId to be a list: ie [4, 6, 8]. Examples indicate that I can do this.
However, ZSQL generates an error every time I put in more than one integer. How
can I pass a list of integers?

Many thanks.
--
Matthew Fairclough
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
ZSQL + MySQL + sqltest + list [ In reply to ]
Hi,

Really frustrated by this.

<dtml-sqltest catId type=int multiple>

I want catId to be a list: ie [4, 6, 8]. Examples indicate that I can do this.
However, ZSQL generates an error every time I put in more than one integer. How
can I pass a list of integers?

Many thanks.
--
Matthew Fairclough


_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: ZSQL + MySQL + sqltest + list [ In reply to ]
Matthew Fairclough wrote:
> Hi,
>
> Really frustrated by this.
>
> <dtml-sqltest catId type=int multiple>
>
> I want catId to be a list: ie [4, 6, 8]. Examples indicate that I can do this.
> However, ZSQL generates an error every time I put in more than one integer. How
> can I pass a list of integers?
>
> Many thanks.
> --
> Matthew Fairclough

What is the exact error? Please show us the complete traceback from the
error.log and the complete ZSQL-Method, please.

Wolfram

_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: ZSQL + MySQL + sqltest + list [ In reply to ]
Matthew Fairclough wrote:
> Hi,
>
> Really frustrated by this.

No need to tell us twice ;-)

> <dtml-sqltest catId type=int multiple>

type=int is for int's only, you're talking about a list of ints...
>
> I want catId to be a list: ie [4, 6, 8].

Hmm, dunno what sqltest does... what are you actually looking to do here?

cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk

_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: ZSQL + MySQL + sqltest + list [ In reply to ]
>What is the exact error? Please show us the complete traceback from the
>error.log and the complete ZSQL-Method, please.

Many thanks. Full query is:

select * from category where
<dtml-sqltest clientAssocList column="clientID" type=int multiple>

Arguments in ZSQL method are:
clientID=0 qID=0 clientAssocList=0 qList=0

Entry in test page is:
ClientAssocList: 4,5,6
(all others at default)

Result is:
--
Error, exceptions.ValueError: Invalid integer value for clientAssocList
--------------------------------------------------------------------------------
SQL used:

Could not render the query template!
--

Does the same thing regardless of input if more than one integer. I need
ClientAssocList to be a list of integers. I don't think it is an SQL or MySQL
issue- but an issue with the ZSQL Method.

Assistance much appreciated.

Regards,

--
Matthew Fairclough
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: ZSQL + MySQL + sqltest + list [ In reply to ]
Chris,

Thanks for your help.

Basically I just want to limit the result to a number of entries based on Id.

As there are several Id's I'm trying for "... where catId IN (x, y, z)".

I could just use a variable that is a list (through REQUEST) but I would like to
ensure the argument is an integer, hence sqltest.

Regards,

Matthew.

Quoting Chris Withers <chris@simplistix.co.uk>:

> Matthew Fairclough wrote:
> > Hi,
> >
> > Really frustrated by this.
>
> No need to tell us twice ;-)
>
> > <dtml-sqltest catId type=int multiple>
>
> type=int is for int's only, you're talking about a list of ints...
> >
> > I want catId to be a list: ie [4, 6, 8].
>
> Hmm, dunno what sqltest does... what are you actually looking to do here?
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Zope & Python Consulting
> - http://www.simplistix.co.uk
>
>


--
Matthew Fairclough
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: ZSQL + MySQL + sqltest + list [ In reply to ]
On 2006-04-05 at 10:39:11 [+0200], Matthew Fairclough
<faircloughm@easp.com.au> wrote:
> Chris,
>
> Thanks for your help.
>
> Basically I just want to limit the result to a number of entries based on
> Id.
>
> As there are several Id's I'm trying for "... where catId IN (x, y, z)".
>
> I could just use a variable that is a list (through REQUEST) but I would
> like to
> ensure the argument is an integer, hence sqltest.

This is one of the reasons why I'm no great fan of <dtml-sqltest>.

You can easily do your checking for an integer in a PythonScript and pass
the result into your ZSQL as a standard DTML variable.

catID = [int(i) for i in catIDs]

Cleaner and quicker than playing the <dtml-sqltest>.

Charlie
--
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2005-10-17: Released mxODBC.Zope.DA 1.0.9 http://zope.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: ZSQL + MySQL + sqltest + list [ In reply to ]
Matthew Fairclough wrote:
>> What is the exact error? Please show us the complete traceback from
>> the error.log and the complete ZSQL-Method, please.
>
>
> Many thanks. Full query is:
>
> select * from category where <dtml-sqltest clientAssocList
> column="clientID" type=int multiple>
>
> Arguments in ZSQL method are: clientID=0 qID=0 clientAssocList=0
> qList=0
>
> Entry in test page is: ClientAssocList: 4,5,6 (all others at default)
>
Ah, you do this from the test-tab of the ZSQL-Method? This is bad,
because every input there is treated as a string (especially if there
are "," in it)
Just write a simple Python-script in the same folder to test the
ZSQL-Method:

# See if the query is rendered correct:
print context.yourZSQLMethodName(clientAssocList=[4,5,6],src__=1)
print context.yourZSQLMethodName(clientAssocList=[4,5,6]).dictionaries()
return printed

> Result is: -- Error, exceptions.ValueError: Invalid integer value for
> clientAssocList
> --------------------------------------------------------------------------------
> SQL used:
>
> Could not render the query template! --
>
> Does the same thing regardless of input if more than one integer. I
> need ClientAssocList to be a list of integers. I don't think it is
> an SQL or MySQL issue- but an issue with the ZSQL Method.
>
> Assistance much appreciated.
>
> Regards,
>
> -- Matthew Fairclough

HTH,
Wolfram

_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db