Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.

Initial transfer of metadata

Ian Edwards edited this page Mar 6, 2020 · 1 revision

This page demonstrates how to export metadata from an existing Climsoft Desktop installation (using MySQL or MariaDB) and import the records into a new Climsoft Web installation (using PostgreSQL).

SHOW DATABASES;
USE mariadb_climsoft_test_db_v4;
SET NAMES utf8;
SHOW VARIABLES LIKE "secure_file_priv";

SELECT * FROM station INTO OUTFILE '/var/lib/mysql-files/station.csv'
  FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  ESCAPED BY '' LINES TERMINATED BY '\n';

SELECT * FROM obselement INTO OUTFILE '/var/lib/mysql-files/obselement.csv'
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  ESCAPED BY '' LINES TERMINATED BY '\n';

You can remove unwanted Windows carridge returns and then copy to the server using Linux commands:

tr -d `\r` < obselement.csv > obselement_wo_cr.csv

scp station.csv obselement_wo_cr.csv inam.climsoft.org:/tmp

Finally, check the current contents of the destination tables and then import into PostgreSQL:

\COPY station FROM '/tmp/station.csv' WITH DELIMITER AS ',' ESCAPE E'\\' NULL AS 'NULL' CSV;
\COPY obselement FROM '/tmp/obselement_wo_cr.csv' WITH DELIMITER AS ',' ESCAPE E'\\' NULL AS 'NULL' CSV;

Clone this wiki locally