Re: Using different types in PyDO2
Jacob Smullyan <[email protected]> Mon, 23 May 2005 12:11:37 -0400
| Newsgroups | gmane.comp.web.skunkweb |
|---|---|
| Message-ID | <[email protected]> |
On Mon, May 23, 2005 at 05:48:24PM +0200, Stefan Neumann wrote:
> Jacob Smullyan wrote:
> > I'm sorry your data is getting mangled. What versions of mysql and
> > MySQLdb are you using?
>
> I'm sorry. Actually it was my mistake. I called the function getSome()
> like this:
>
> all=Rule.getSome("id != %d",self.defaultID)
>
> I was thinking, that I have to use %d because defaultID should be an
> int. But I got this message:
>
> TypeError: int argument required
>
> So I conclude, defaultID had to be an string because:
>
> all=Rule.getSome("id != %s",self.defaultID)
>
> worked. ;-)
This highlights a difference between using strings with getSome and
using operators syntax -- with strings you have to use bind variables
according to a style accepted by the underlying driver, and with
operators you don't need them.
So these are equivalent to the above:
all=Rule.getSome(NE(FIELD('id'), self.defaultID))
# which is the same as
all=Rule.getSome(('!=', FIELD('id'), self.defaultID))
Choose your poison.
Cheers,
js
--
Jacob Smullyan
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCkgC5uqamFyFXXLIRAvRxAJ494TTELt5oK4QLBL65v8y4itGD2wCgrsO0 GMqe1oBS/LuceKZTwEFpa9s= =QSHt -----END PGP SIGNATURE-----