Created
December 6, 2015 12:28
-
-
Save ikuwow/59064ae4e052b096b75c to your computer and use it in GitHub Desktop.
スプレッドシートでCSV吐き出して小さなDBのテストデータを作ると結構楽だった ref: http://qiita.com/ikuwow/items/a783a83924f88c48a1b5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mysql -u root application --local-infile=1 | |
mysql > load data local infile './users.csv' into table users fields terminated by ',' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 ',' | |
" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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