load_data.sh 548 B

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