Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Sqoop Export - Hive to MySQL

Prepare Source

# Copy sales.log locally 
hadoop fs -copyToLocal /data/hive/sales.log

#Launch hive using command: hive
# Create Hive Table:
use sg;
CREATE TABLE sales_test(widget_id INT, qty INT,
street STRING, city STRING, state STRING,
zip INT, sale_date STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';

# Find the location of your table using:
describe formatted sales_test;
# Load Data:
LOAD DATA LOCAL INPATH "sales.log" INTO TABLE sales_test;
# Select rows to see data:
select * from sales_test;

Prepare MySQL Table

#TO launch mysql:
    mysql -h cxln2.c.thelab-240901.internal -u sqoopuser -p

#Create MYSQL Table:
use sqoopex;
CREATE TABLE sales_sgiri(widget_id INT, qty INT, street varchar(100), city varchar(100), state varchar(100),
zip INT, sale_date varchar(100));

Sqoop Export - Hive To MySQL

# Sqoop Export:
sqoop export --connect jdbc:mysql://cxln2.c.thelab-240901.internal/sqoopex -m 1 --table sales_sgiri --export-dir /apps/hive/warehouse/sg.db/sales_test --input-fields-terminated-by ',' --username sqoopuser --password NHkkP876rp;

# Go back to the MySQL prompt and check
use sqoopex;
select * from sales_sgiri;


No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...