Postgresql - import CSV data

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
chkaufmann
Posts: 82
Joined: Sat 01 Jul 2006 11:42

Postgresql - import CSV data

Post by chkaufmann » Thu 11 Jun 2020 15:42

Hi,

with a TUniQuery I can run a command like:

Code: Select all

copy mytable(col1,col2) from 'testdata.csv' delimiter ',' csv
This works fine when the csv file is placed on the server.
Now I have my file on the client computer and it doesn't work. I can do it with the command line tool psql.exe (\copy command) but my question is, if there is a way to run it from inside my Delphi application.

Christian

oleg0k
Devart Team
Posts: 190
Joined: Wed 11 Mar 2020 08:28

Re: Postgresql - import CSV data

Post by oleg0k » Wed 17 Jun 2020 10:34

Hello,
The Copy command is executed by PostgreSQL server, not UniDAC components. The server uses a local file system ( https://www.postgresql.org/docs/current/sql-copy.html ).
To load data from a file to a table on the client side, you can use the TUniLoader component in UniDAC or psql.exe.

wbr, Oleg
Devart Team

Post Reply