question about libpq
От | Jay Campbell |
---|---|
Тема | question about libpq |
Дата | |
Msg-id | 3442EA66-81D4-11D8-B35C-000A9599CF8E@mac.com обсуждение исходный текст |
Ответы |
Re: question about libpq
|
Список | 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
В списке pgsql-novice по дате отправления: