Re: psycopg2 open file for reading

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: psycopg2 open file for reading
Дата
Msg-id 5630E1EF.1000002@aklaver.com
обсуждение исходный текст
Ответ на Re: psycopg2 open file for reading  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
Список psycopg
On 10/28/2015 07:42 AM, Shulgin, Oleksandr wrote:
> On Wed, Oct 28, 2015 at 3:35 PM, Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
>
>
>     The cheat is to read the on disk file and write it into an in memory
>     file and then use that with STDIN. Something like:
>
>     sql_copy = "COPY " + self.pg_tbl_name
>     sql_copy += " FROM STDIN WITH CSV DELIMITER '\t'"
>     cur_copy.copy_expert(sql_copy, mem_file)
>
>
> And you don't actually need a "memory file", any object implementing
> "read" method, such as a normal fie object should just work:
>
> file=open('1.txt', 'r')
> cur_copy.copy_expert(sql_copy, file)

Hmm, I was over thinking this. Thanks for the simplification.

>
> --
> Alex
>


--
Adrian Klaver
adrian.klaver@aklaver.com


В списке psycopg по дате отправления:

Предыдущее
От: "Shulgin, Oleksandr"
Дата:
Сообщение: Re: psycopg2 open file for reading
Следующее
От: Dan Sawyer
Дата:
Сообщение: Re: psycopg2 open file for reading