escaping data for copy_from()

Поиск
Список
Период
Сортировка
От Josh Kupershmidt
Тема escaping data for copy_from()
Дата
Msg-id CAK3UJRHrrsNjoOm54NYJT_O15Wh-jDcm1332OYraZxVJhN3S6Q@mail.gmail.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Federico Di Gregorio
Дата:
Сообщение: Re: [snafu] isolation-level change in 2.4.2
Следующее
От: Federico Di Gregorio
Дата:
Сообщение: RELEASE: psycopg 2.4.4