Question(s) about the use of PgSQL.PgUnQuoteBytea
Luc Stepniewski <[email protected]> Thu, 3 Jul 2003 15:22:19 +0200
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Organization | Adelux |
| Message-ID | <[email protected]> |
I put some data in a table, which has a record of type 'bytea'.
I inserted that data using the PgSQL.PgQuoteBytea method.
When I want to extract the data, (I guess) I need, just after retrieving the
result(s) from a SELECT, to use PgSQL.PgUnQuoteBytea.
But when I use it, I get the error "PgUnQuoteString() argument 1 must be
string, not instance' ".
Doing a "print myinstance.__class__" prints 'pyPgSQL.PgSQL.PgBytea'. So I
guess it's ok, so why do I get an error?
Here is the snippet of code I used:
===========
recup = """SELECT docbody FROM docs where docid=%s """ %
PgSQL.PgQuoteString(form.getvalue('docid'))
cur.execute(recup)
res = cur.fetchall()
print PgSQL.PgUnQuoteBytea(res[0]['docbody'])
===========
Looking at the documentation for the methods, I see that PgUnQuoteBytea takes
a string as parameter (!?), so if I try to stringify it, I get the following
error: "Bad input string for type bytea", doing this:
===========
c = `res[0]['docbody']`
d = PgSQL.PgUnQuoteBytea(c)
===========
Any idea?
Thanks,
Luc Stepniewski
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01