- #!/bin/bash
- #load_data.sh
- #USAGE: sh load_data.sh [table_name] [filename]
- #sh load_data.sh transcript_info_x /tmp/transcript_info.tsv
- DB_USER='root' #'your_db_username'
- DB_PASS='root' #'your_password'
- DB='my_genie_sys_database' #'database_name'
- mysql --host=localhost --user=$DB_USER --password=$DB_PASS --local_infile=1 --database=$DB <<EOFMYSQL
- TRUNCATE TABLE $1;
- ALTER TABLE $1 AUTO_INCREMENT = 1;
- load data local infile '$2' ignore INTO TABLE $1 CHARACTER SET UTF8 fields terminated by '\t' LINES TERMINATED BY '\n' ignore 0 lines;
- EOFMYSQL
|