Skip to Content
Apache Sqoop Cookbook
book

Apache Sqoop Cookbook

by Kathleen Ting, Jarek Jarcec Cecho
July 2013
Intermediate to advanced content levelIntermediate to advanced
94 pages
1h 52m
English
O'Reilly Media, Inc.
Content preview from Apache Sqoop Cookbook

Chapter 5. Export

The previous three chapters had one thing in common: they described various use cases of transferring data from a database server to the Hadoop ecosystem. What if you have the opposite scenario and need to transfer generated, processed, or backed-up data from Hadoop to your database? Sqoop also provides facilities for this use case, and the following recipes in this chapter will help you understand how to take advantage of this feature.

Transferring Data from Hadoop

Problem

You have a workflow of various Hive and MapReduce jobs that are generating data on a Hadoop cluster. You need to transfer this data to your relational database for easy querying.

Solution

You can use Sqoop’s export feature that allows you to transfer data from the Hadoop ecosystem to relational databases. For example, to export data from the export-dir directory cities (the directory in HDFS that contains the source data) into table cities (the table to populate in the database), you would use the following Sqoop command:

sqoop export \
  --connect jdbc:mysql://mysql.example.com/sqoop \
  --username sqoop \
  --password sqoop \
  --table cities \
  --export-dir cities

Discussion

Export works similarly to import, except export transfers data in the other direction. Instead of transferring data from the relational database using SELECT queries, Sqoop will transfer the data to the relational database using INSERT statements. Sqoop’s export workflow matches the import case with slight differences. After you execute ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Apache Sqoop

Mastering Apache Sqoop

David Yahalom
Apache Hive Cookbook

Apache Hive Cookbook

Hanish Bansal, Saurabh Chauhan, Shrey Mehrotra
Apache Spark Quick Start Guide

Apache Spark Quick Start Guide

Shrey Mehrotra, Akash Grade

Publisher Resources

ISBN: 9781449364618Errata PageSupplemental Content