sqoop - sqoop Import RDBMS Table to HDFS - apache sqoop - sqoop tutorial - sqoop hadoop



sqoop Import RDBMS Table to HDFS

sqoop import \
--connect  <rdbms-jdbc-url> \
--username  <username> \
--password  <password> \
--table  <table-name>
Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team
  • Example with Mysql:
  • sqoop import \
    --connect jdbc:mysql://mysql.example.com/testdb \
    --username root \
    --password root \
    --table employees
    Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team
  • CSV file with the imported data will be created under employees directory under home directory.
  • Inspect using command:
  • hadoop fs -cat  <hdfs-home-dir>/employees/part-m-* 
    Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team
  • Import to a particular directory in HDFS
  • sqoop import \
    --connect jdbc:mysql://mysql.example.com/testdb \
    --username root \
    --password root \
    --table emplyoees \
    --target-dir /dev/data/employees
    Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team
  • This will generate CSV file under /dev/data/employees directory.
  • Specify parent HDFS directory for Sqoop job
  • sqoop import \
    --connect jdbc:mysql://mysql.example.com/testdb \
    --username root \
    --password root \
    --table emplyoees \
    --warehouse-dir /dev/warehouse/
    Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team
  • --warehouse-dir tag in above command will change your home directory to /dev/warehouse/
  • Import subset of RDBMS Table to HDFS

  • Using --where tag
  • sqoop import \
    --connect  <rdbms-jdbc-url> \
    --username  <username> \
    --password  <password> \
    --table  <table-name> \
    --where "<condition>"
    Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team
    sqoop import \
    --connect jdbc:mysql://mysql.example.com/testdb \
    --username root \
    --password root \
    --table employees \
    --where "country = 'INDIA'"
    Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team
  • Any special functions, conversions, or even user-defined functions can be used in --where clause.
  • Using Free Form Query

    sqoop import \
    --connect  <rdbms-jdbc-url> \
    --username  <username> \
    --password  <password> \
    --query  <sql-query> \
    --target-dir  <target-dir>
    Click "Copy code" button to copy into clipboard - By wikitechy - sqoop tutorial - team

    SQOOP forum

    Sqoop Installation and Download :

    Connecting Sqoop to other databases/datastores :

  • Import data directly into Hive Warehouse
  • Import data from RDBMS to HBase table
  • Import data to new catalog
  • Import the results of a query from a relational database into HDFS
  • Load JDBC Driver
  • Sqoop Export :

  • Sqoop Export basic example
  • Sqoop Import RDBMS Table to HDFS :

  • Sqoop Import RDBMS Table to HDFS
  • Merge data-sets imported via incremental import using Sqoop :

  • Import New as well as Updated Data - lastmodified mode - Append Mode
  • Hadoop with Kite SDK :

  • Kite SDK to demonstrate copying of various file formats to Hadoop
  • Sqoop Advanced :

  • Use Sqoop to copy an Oracle table to Hadoop

  • Related Searches to sqoop Import RDBMS Table to HDFS