Re: Error using row object as args for a query
Gerhard Häring <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
TiNo wrote:
> I try to use the outcome of a select statement in another query doing
> the following:
>
> [...]
>>>> cur.execute('DELETE FROM test WHERE a = :a',(x,))
> Traceback (most recent call last):
> File "<input>", line 1, in ?
> InterfaceError: Error binding parameter 0 - probably unsupported type.
>
> --------------------------------------------------------------------------------------------------------------------
>
> But that doesn't work...
> My fault? Bug? how do I do this?
If you use a sequence as parameter, you need to use the question mark as
placeholder, and if you use a dictionary as parameter, you need to use
named placeholders (:name). So you can use either
>>> cur.execute('DELETE FROM test WHERE a = ?',(x,))
or
>>> cur.execute('DELETE FROM test WHERE a = :a', {"a": x})
- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFGErzdIO4ozGCH14RAoSdAKC1G4TyPs3Ctm6TNaCMONuMy+nejwCdEYN+
zowDthjEuY+9XGRFg/rkOEw=
=MitL
-----END PGP SIGNATURE-----