Wednesday, 25 May 2016

Sqoop & SQL Server #5 - Basic Sqoop Commands

Version
To check that sqoop is running you can execute a version command. All this does is return the currently installed version of sqoop but by returning that information you are confirming that sqoop is running.

sqoop version

The command has no arguments and returns the following;

16/05/26 08:37:22 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.7.0
Sqoop 1.4.6-cdh5.7.0
git commit id
Compiled by jenkins on Wed Mar 23 11:31:09 PDT 2016

List Databases
A simple connectivity check is to run a list-databases command. This command simply lists the databases your user is allowed to see.

sqoop list-databases --connect "jdbc:sqlserver://10.88.12.0:1433;username=ClouderaAccess;password=GiveMeData"

The syntax is very simple. You only need to use the connect argument.

Connect specifies the connection string in which the server, port, username and password need to be supplied.

--connect "jdbc:sqlserver://[server]:[port];username=[username];password=[password]"

The output is a simple list of databases

master
tempdb
model
msdb
Utility

List Tables
Similar to the list databases command is list-tables. 

sqoop list-tables --connect "jdbc:sqlserver://10.88.12.0:1433;database=Utility;username=ClouderaAccess;password=GiveMeData"

Again the syntax is pretty simple requiring just a connect argument. But in this case you need to specify the database in the connection string as well.

--connect "jdbc:sqlserver://[server]:[port];database=[database];username=[username];password=[password]"

No comments:

Post a Comment