Skip to content

Instantly share code, notes, and snippets.

@OXPHOS
Last active June 10, 2018 15:30
Show Gist options
  • Save OXPHOS/9680a58e17c87126c6b72846975d5c00 to your computer and use it in GitHub Desktop.
Save OXPHOS/9680a58e17c87126c6b72846975d5c00 to your computer and use it in GitHub Desktop.
From installing mysql to load csv to sql tables

Install Mysql:

export PATH=$PATH:/usr/local/mysql/bin

Run Mysql:

mysql -uroot -ppassword

CREATE DATABASE dbname;

(mysql --local_infile -uroot -ppassword dbname)

Automatic load csv with schema to db:

brew install mysql
pip install mysql-python
conda install csvkit
csvsql --db "mysql://root:password@localhost:3306/dbname" --insert raw/inpatient/inpatient.txt
# (csvsql --dialect mysql raw/inpatient/inpatient.txt > inpatient.sql) # Schemas only

NOTE: mysql-python only works with py2 NOTE: potential error and solution: https://stackoverflow.com/questions/49194719/authentication-plugin-caching-sha2-password-cannot-be-loaded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment