COPY and binary data

From: Юрий EGO <mail_ego(at)list(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: COPY and binary data
Date: 2011-06-07 12:47:26
Message-ID: E1QTvgs-0006z8-00.mail_ego-list-ru@f3.mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

I have a code (libpq):

char textbuffer[120];
res = PQexec(conn, "COPY table_name(\"serial_column",\"int_column",\"bytea_column\") FROM STDIN");
if(PQresultStatus(res) == PGRES_COPY_IN)
{
for(int n=0; n < 10; n++) {
sprintf(textbuffer, "1\t%i\t'text'\n", n);
int copydatares = PQputCopyData(conn, textbuffer, strlen(textbuffer));
}
PQputCopyEnd(conn, NULL);
} 

For text data it's ok, but binary data may have '\n' or '\t' characters.
How  correctly write int STDIN binary data?

Help me please! 
Thanks in advance.



Browse pgsql-general by date

  From Date Subject
Next Message Thomas Guettler 2011-06-07 14:25:28 Re: Recurring events
Previous Message Юрий EGO 2011-06-07 12:46:17