Thread: Bulk Load and Extract from PostgreSQL

Bulk Load and Extract from PostgreSQL

From
Sandeep Khandelwal
Date:
Hi All.

I want to read and write bulk data into PostgreSQL using Libpq C API and right now I am under the investigation phase.
Alsowant to delete and update into PostgreSQL using Libpq API. 

PLease let me know

Read -
I am planning to use COPY DATA TO command in TEXT mode for reading, I am using PQgetCopydata function to get data one
rowat a time. 
Problem -
a - Not sure whether PQgetCopydata will give NULL terminated string or \n terminated string.
b - I know that PQgetCopydata API will give data of all the rows , seperated by delimiter, in TEXT format. But don't
knowhow to convert this text data into corresponding data type, especially BYTEA. 
c - Don't know what are the special characters and how these are handeled by PQgetCopydata and How I should hendel
them.

Load -
I am planning to use COPY DATA FROM command in TEXT mode for writing, I am using PQputCopydata function to send data
onerow at a time. 
Problem -
a - Not sure what are the special characters and how I should miodify them.
b - PQputCopydata API takes data of all the rows, seperated by delimiter, ini string representation. Don't know how to
convertall the datatypes into string representation, especially BYTEA. 

Waiting for reply.

Thanks,
Sandep