From: David H. <df...@fo...> - 2006-11-22 11:45:09
|
Hello, I'm in the process of extending an existing Python application that uses pySqlite to use postgreSQL with pypgsql as an alternative dbms (for use by up to 50 students simultaneously in a class) and nearly everything is working just fine. I'm using bytea columns to store binary strings that are mainly cPickled strings and, in accordance with the pypgsql README I'm using: PgQuoteBytea: Escapes a string, which can contain NUL characters, so that it can used as an input to a bytea field. PgUnQuoteBytea: Reverses the action of PgQuoteBytea(). But these don't seem to be completely symmetrical. The quote function also encloses the whole string in single-quotes (why does it need to do this?) and any embedded single-quote characters are escaped as two single-quotes (documented as a security update in pypgsql 2.5) but neither of these are reversed by the unquote function. I can work round this by using an construct like: sout = PgSQL.libpq.PgUnQuoteBytea(bstring.value).replace("''","'")[1:-1] but I'd like to check, first, if it's really necessary to do this - I may be doing something wrong somewhere, and second, is this a safe solution in the general case? -- Regards, David Hughes |