escaping data for copy_from() - Mailing list psycopg

From Josh Kupershmidt
Subject escaping data for copy_from()
Date
Msg-id CAK3UJRHrrsNjoOm54NYJT_O15Wh-jDcm1332OYraZxVJhN3S6Q@mail.gmail.com
Whole thread Raw
List psycopg
Hi all,

I haven't seen a built-in way to escape data meant for copy_from().
The example code in examples/copy_from.py uses only pre-escaped data
e.g:

  data.write('\n'.join(['Tom\tJenkins\t37',
                        'Madonna\t\N\t45',
                        'Federico\tDi Gregorio\t\N']))

which works OK for such pre-escaped data, but what I really want is a
way to escape arbitrary text blobs for use with copy_from() -- for
instance, text containing newlines, tabs, backslash characters, and
other sequences which need escaping.

Is there some easy way to handle this problem I'm missing, or do I
need to just write my own escaping code?

Josh

psycopg by date:

Previous
From: Federico Di Gregorio
Date:
Subject: Re: [snafu] isolation-level change in 2.4.2
Next
From: Federico Di Gregorio
Date:
Subject: RELEASE: psycopg 2.4.4