Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Insert CSV file to Postgres from qlikview.

Hi all,

I have scenario where in my qlikview report is generating csv file and i have to insert those csv file into Postgres database.

In sort i have to wtite back to database.

any help would be appreciated.

thanks in advance.

5 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Since everything is external to your document, you can write a .cmd file that performs a Postgres Import from that particular csv, and launch it

  • from your load script by using the EXECUTE statement
  • from your UI by creating a button and attaching an External->Launch action type

Good luck,

Peter

Not applicable
Author

Thanks peter..could u pls help me with nay ex. or demo.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

I don't have any experience with Postgres so I cannot write the .cmd file for you. Usually you will have to call a SQL command line client and pass it a SQL query source file. The only thing that source file has to contain is some sort of SQL IMPORT statement that opens an external file and drops its contents in a specific table.

Once you store that command in a .cmd (batch) file, you have to choose how to call this command file. If you want to write to the DB at the end of your load script, then add a statement like

EXECUTE 'C:\CmdFiles\ImportIntoPostgress.cmd';

at the end of your script.

On the other hand, if you want to execute the import from the QlikView user interface, add a button to your sheet, open Button->Properties->Actions, click the Add button, on the left select External, then on the right select Launch and click OK. A new action layout appears. Click the Browse button at the top right, navigate to your .cmd file and click OK. Then click Apply or OK and the action will be attached to your button.

That's about it, I think

Peter

Not applicable
Author

hello All,

still not got the solution for aboce problem.

I have a CSV file whcih i have to insert in postgres table.I raed somewhere we can use 'COPY"

(COPY postgres_table FROM 'wheat_crop_data.csv' DELIMITER ';' CSV
HEADER ) command in postgres for importing CSV file directly into it.

BUT How can i do this using batch file.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

There is a command line tool called psql that allows you to execute single SQL statements on a remote Postgres database. For details about the command line syntax, see http: //www.postgresql.org/docs/9.3/static/app-psql.html (remove the space before the slashes). For example, to execute a single copy-from-csv as specified in your question, do something like:

[Path-to-psql]\psql.exe -c " COPY postgres_table FROM 'wheat_crop_data.csv' DELIMITER ',' FORMAT CSV HEADER"

Put this statement in a .cmd file and execute it from within QlikView.

Of course, you'll have to add parameters to specify database name, username, password and the likes. You'll find all the details in the documention by using the above URL.

Good luck,

Peter