Prashant Singh
Prashant Singh

Reputation: 1

How to import table from PostgreSQL to SAP Hana?

I'm trying to export data from PostgreSQL and import it into SAP Hana. The problem which is '\n' i.e. line breaks are getting automatically removed from the TEXT data.

Example:

A 1,750 word essay is 11 to 12 paragraphs.
A 2,000 word essay is 13 to 14 paragraphs.
A 2,500 word essay is 16 to 17 paragraphs.
A 3,000 word essay is 20 paragraphs.

Is becoming

A 1,750 word essay is 11 to 12 paragraphs.A 2,000 word essay is 13 to 14 paragraphs.A 2,500 word essay is 16 to 17 paragraphs.A 3,000 word essay is 20 paragraphs.

I'm using below commands:

PostgreSQL

\COPY table_name TO 'path\data.csv' WITH CSV DELIMITER ',';

Hana

IMPORT FROM CSV FILE path
INTO table_name
WITH RECORD DELIMITED BY '\n'
FIELD DELIMITED BY '\t'
OPTIONALLY ENCLOSED BY '"';

Upvotes: 0

Views: 561

Answers (2)

Mathias Kemeter
Mathias Kemeter

Reputation: 1183

Instead of exporting and importing CSV files, you could use DBeaver, which supports both - SAP HANA and PostgreSQL.

An instruction for moving data between dbms can be found here: https://dbeaver.com/docs/wiki/Data-migration

Upvotes: 0

redhatvicky
redhatvicky

Reputation: 1930

To have the \ to be recognized as a escape character it is necessary to use the text format.

COPY table_name  from 'path\data.csv' delimiter ',' TEXT

Source : Postgres COPY command with literal delimiter

Upvotes: 0

Related Questions