Skip to content

An extension of DbSetup to import data from CSV/TSV files.

License

Notifications You must be signed in to change notification settings

sciencesakura/dbsetup-csv

Repository files navigation

dbsetup-csv: Import CSV using DbSetup

English | 日本語

A DbSetup extension to import data from CSV/TSV files.

Maven Central

Requirements

  • Java 11+

Installation

Gradle

Java

testImplementation 'com.sciencesakura:dbsetup-csv:3.0.0'

Kotlin

testImplementation 'com.sciencesakura:dbsetup-csv-kt:3.0.0'

Maven

Java

<dependency>
  <groupId>com.sciencesakura</groupId>
  <artifactId>dbsetup-csv</artifactId>
  <version>3.0.0</version>
  <scope>test</scope>
</dependency>

Kotlin

<dependency>
  <groupId>com.sciencesakura</groupId>
  <artifactId>dbsetup-csv-kt</artifactId>
  <version>3.0.0</version>
  <scope>test</scope>
</dependency>

Usage

Java

import static com.sciencesakura.dbsetup.csv.Import.csv;

@BeforeEach
void setUp() {
  var operations = sequenceOf(
    truncate("my_table"),
    // `testdata.csv` must be in classpath.
    csv("testdata.csv").into("my_table").build());
  var dbSetup = new DbSetup(destination, operations);
  dbSetup.launch();
}

Kotlin

import com.sciencesakura.dbsetup.csv.csv

@BeforeEach
fun setUp() {
  dbSetup(destination) {
    // `testdata.csv` must be in classpath.
    csv("testdata.csv") {
      into("my_table")
    }
  }.launch()
}

See API reference for details.

Prefer Excel ?

dbsetup-spreadsheet

License

MIT License

Copyright (c) 2019 sciencesakura