Getting the data into mysql db

 

book1:page 26:
URL http://www2.census.gov/acs2011_1yr/pums/csv_pus.zip
URL http://www2.census.gov/acs2011_1yr/pums/csv_hus.zip

 

data was not properly loaded, no delimiter specified in the load data infile command when we run.

need to fix this:

First truncate the table, then modify the load data infile command add Fields terminated by “,” in the loading command. Check and see the data load correctly, do the same for Hus_b, pus_a, pus_b;

back to OS to compare the lines in files

table rows are exactly one less than the lines in files for each, yeeeeeeeeeee.

install.packages(“RMySQL”)
library(RMySQL)
Connecting to MySQL:
Once the RMySQL library is installed create a database connection object.

mydb = dbConnect(MySQL(), user=’user’, password=’password’, dbname=’database_name’, host=’host’)
Listing Tables and Fields:
Now that a connection has been made we list the tables and fields in the database we connected to.

dbListTables(mydb)

This will return a list of the tables in our connection.

dbListFields(mydb, ‘some_table’)

 

Leave a Reply

Your email address will not be published. Required fields are marked *