0

In usual migration I am using SQL usual COPY CSV command, but now all the SpringBoot project must be into a git and generic path for clone (and do it in a protected server):

  • where the best place or "standard Spring folder" to CSV files used by main/resources/db/migration?

  • how to use the COPY (SQL) with a relative path?


Relative path by shell is:

psql -h localhost -U postgres gcp -c    "\
  CREATE TABLE question_import (question text, weight integer); \
  COPY question_import FROM STDIN WITH CSV HEADER delimiter as ',' \
"    < _docs/data/csc-questoes.csv

but PostgreSQL not supports internal relative path.

2
  • But you will use psql in any case? Or another client? Commented Jan 24, 2017 at 10:07
  • @TommasoDiBucchianico Hum... Ideal is to use "only db/migration", independent of other server-side intalls Commented Jan 24, 2017 at 10:51

1 Answer 1

1

Once you're using SpringBoot, why not incorporating the benefits of Liquibase (section 75.5.2)?

Apart from the ability to define/version your database schema, there are also methods for loading data, e.g. CSV in your case:

<changeSet author="liquibase-docs" id="loadUpdateData-example">
<loadUpdateData catalogName="cat"
        encoding="UTF-8"
        file="com/example/users.csv"
        primaryKey="pk_id"
        quotchar="A String"
        schemaName="public"
        separator="A String"
        tableName="person">
    <column name="address" type="varchar(255)"/>
</loadUpdateData>

The Spring-Boot-Liquibase Sample project should give you a quickstart.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.