Skip to content

Instantly share code, notes, and snippets.

@ikuwow
Created December 6, 2015 12:28
Show Gist options
  • Save ikuwow/59064ae4e052b096b75c to your computer and use it in GitHub Desktop.
Save ikuwow/59064ae4e052b096b75c to your computer and use it in GitHub Desktop.
スプレッドシートでCSV吐き出して小さなDBのテストデータを作ると結構楽だった ref: http://qiita.com/ikuwow/items/a783a83924f88c48a1b5
create table if not exists users (
id serial not null primary key,
email varchar(255) not null,
name varchar(255) not null,
password varchar(255) not null,
created datetime not null default now()
) engine=innodb;
$ mysql -u root application --local-infile=1
mysql > load data local infile './users.csv' into table users fields terminated by ','
#!/bin/bash
mysql -u root --execute="drop database application"
mysql -u root --execute="source schema.sql"
mysql -u root --local-infile=1 application --execute="\
load data local infile './users.csv' into table users fields terminated by ','
"
1 [email protected] testname1 password1
2 [email protected] testname2 password2
3 [email protected] testname3 password3
4 [email protected] testname4 password4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment