Helpful guides and examples to make life easier.
This code demonstrates how to upload files into SQL. The files should begin as a .csv
file, typically from a dataframe.
Useful rescources with more detail:
https://grid.rcs.hbs.org/importing
https://grid.rcs.hbs.org/import-and-export-text-files
A. Format File - prepare the file for upload into SQL database by changing its format into a pipe-separated (|
) .txt
file
B. Create Database - enter the GRID (or SecureCRT) and use the following commands on the command line interface.
mysql
use agoldenberg_twitter_data;
create table table_import (Column_1 char(20), Column_2 char(20), Column_3 char(20));
- this command should have also appeared in the file formatter aboveCreate Import Directory
mkdir /export/mdb_external/import/username
chmod 700 /export/mdb_external/import/username
Move File
pwd
#Get the full directory of your desktop where your file is
returns for example: /export/home/rcsguest/rcs_username/Desktop
mv /export/home/rcsguest/rcs_username/Desktop/SampleData.txt /export/mdb_external/import/username
Import File
mysql
use agoldenberg_DATABASENAME;
load data local infile '/export/mdb_external/import/username/SampleData.txt' into table table_import fields terminated by '|' lines terminated by '\n' ignore 1 lines;
Check Data
Describe TABLENAME;
SELECT * FROM TABLENAME;
Remove temp-import files & folder