From: | Jay Campbell <fork42(at)mac(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | question about libpq |
Date: | 2004-03-29 22:55:41 |
Message-ID: | 3442EA66-81D4-11D8-B35C-000A9599CF8E@mac.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hello all. I am trying to use libpq to store some large blocks of text
in a postgresql table, and I can't figure out how to make it behave
like I want. Any advice would be very welcome.
I have a large block of text coming in on STDIN, and I would like to
dump it all to a given field. In a perfect world, I could just do
this:
PQmagicFunction(conn, my_row_oid, my_field_number, STDIN);
...and it would grab the data from STDIN and append it to the given
field in the given row, until EOF. Now, since PQmagicFunction doesn't
exist (as far as I know), I could buffer it and do the following:
char buffer[1024];
PQaddFromCharacterBufferToField(conn, my_row_oid, my_field_number,
buffer, 1024);
but again, I haven't seen PQaddFromCharacterBufferToField(PGconn *,
Oid, int, char *, int) in any of the header files. :)
...as it stands, i'm having to escape the buffer contents and do a
PQexec 'update' command that appends the 1024 escaped characters to the
field, every time the buffer fills. (which could be thousands of times
as the filesize could be in the megabytes) Perhaps I'm doing it right,
but it sure feels icky. I keep getting this feeling that there is a
better way (or two).
can someone point me in the right direction please? If my explanation
didn't make sense, please tell me that too.
Thanks in advance,
-jay
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2004-03-29 23:06:59 | Re: question about libpq |
Previous Message | Josh Berkus | 2004-03-29 21:46:05 | Re: dynamic interval in plpgsql |