cy.lee
cy.lee

Reputation: 57

Export data from client to server via postgresql ODBC

I wish to upload my text data from client application to server database. Right now, i'm using ODBC to communicate with PostgreSQL. I use ODBC because there is a need to connect to multiple type of databases.

My issue here is, PostgreSQL uses PQgetCopyData to obtain the stdout data when using COPY OUT. So, is there any workaround to obtain the data from output stream without using libpq API and transmit it over by :

SQLExecDirect (hStmst,"COPY <table> FROM STDIN WITH CSV ",SQL_NTS)

?

Upvotes: 0

Views: 523

Answers (1)

Chris Travers
Chris Travers

Reputation: 26464

Basically you have two options. The first is to use the old COPY command (borrowed from Quel interestingly enough). The second is to use a CSV parsing library of your choice and generate INSERT statements.

The tradeoff is that COPY will work MUCH faster, whine INSERT will work on other databases too.

Upvotes: 1

Related Questions