You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@sqoop.apache.org by VKing Gorri <vk...@yahoo.com> on 2013/08/09 02:00:57 UTC

Capture record cound using sqoop eval

Hi,
 
I would like to store record count of a MySQL table in a variable using sqoop eval. How could I suppress the formatting from the QueryResult and just get count so that I could export the value to a variable?  Please suggest.
 
sqoop eval --connect <> --username <>--password <> --query "select count(1)  from table_nm"
------------------------
| count(1)             |
------------------------
| 3768                 |
------------------------

Thanks!

Re: Capture record cound using sqoop eval

Posted by VKing Gorri <vk...@yahoo.com>.
Hi Jarcec,

Thanks for your suggestion, I take this one.

Thanks,
Varun

________________________________
 From: Jarek Jarcec Cecho <ja...@apache.org>
To: user@sqoop.apache.org; VKing Gorri <vk...@yahoo.com> 
Sent: Sunday, August 11, 2013 11:07 AM
Subject: Re: Capture record cound using sqoop eval
 

Hi VKing,
Sqoop is highly optimized tool for transferring data between relational databases and Hadoop ecosystem. It's not a general purpose querying tool. The tool "eval" stands for "evaluation" and should be used only for validating the connection status using simple queries. It should not be used in production workflows. I would suggest to use mysql utility itself for this purpose.

Jarcec

On Thu, Aug 08, 2013 at 05:00:57PM -0700, VKing Gorri wrote:
> Hi,
>  
> I would like to store record count of a MySQL table in a variable using sqoop eval. How could I suppress the formatting from the QueryResult and just get count so that I could export the value to a variable?  Please suggest.
>  
> sqoop eval --connect <> --username <>--password <> --query "select count(1)  from table_nm"
> ------------------------
> | count(1)             |
> ------------------------
> | 3768                 |
> ------------------------
> 
> Thanks!

Re: Capture record cound using sqoop eval

Posted by Jarek Jarcec Cecho <ja...@apache.org>.
Hi VKing,
Sqoop is highly optimized tool for transferring data between relational databases and Hadoop ecosystem. It's not a general purpose querying tool. The tool "eval" stands for "evaluation" and should be used only for validating the connection status using simple queries. It should not be used in production workflows. I would suggest to use mysql utility itself for this purpose.

Jarcec

On Thu, Aug 08, 2013 at 05:00:57PM -0700, VKing Gorri wrote:
> Hi,
>  
> I would like to store record count of a MySQL table in a variable using sqoop eval. How could I suppress the formatting from the QueryResult and just get count so that I could export the value to a variable?  Please suggest.
>  
> sqoop eval --connect <> --username <>--password <> --query "select count(1)  from table_nm"
> ------------------------
> | count(1)             |
> ------------------------
> | 3768                 |
> ------------------------
> 
> Thanks!

Re: Capture record cound using sqoop eval

Posted by Abraham Elmahrek <ab...@cloudera.com>.
Hey User,

I don't think it's possible. Looking at EvalSqlTool.java, it looks like
"ResultSetPrinter" is used in all cases. You should be able to use grep or
awk to extract the result.

-Abe


On Thu, Aug 8, 2013 at 5:00 PM, VKing Gorri <vk...@yahoo.com> wrote:

> Hi,
>
> I would like to store record count of a MySQL table in a variable using
> sqoop eval. How could I suppress the formatting from the QueryResult
> and just get count so that I could export the value to a variable?  Please
> suggest.
>
> sqoop eval --connect <> --username <> --password <> --query "select count(1)
> from table_nm"
> ------------------------
> | count(1)             |
> ------------------------
> | 3768                 |
> ------------------------
> Thanks!
>