Export query result to csv file

Moderator: NorbertKrupa

prsekhar13
Newbie
Newbie
Posts: 6
Joined: Wed Feb 26, 2014 9:05 am

Export query result to csv file

Post by prsekhar13 » Fri Nov 14, 2014 12:57 pm

Hi,
I am trying to export my query result to csv file by using below command. When i try to execute below command, file is exporting in linux machine where the vertica installed
But i just want to export file into my local machine.
Is it possible with vsql?

vsql -U test -d db_name -h 1.0.0.0 -w vertica -c "select * from export_query_result " -Aq -P footer=off -F ',' -o "/tmp/exaple.csv"

Can i execute above command using .NET?

NorbertKrupa
GURU
GURU
Posts: 527
Joined: Tue Oct 22, 2013 9:36 pm
Location: Chicago, IL
Contact:

Re: Export query result to csv file

Post by NorbertKrupa » Fri Nov 14, 2014 4:03 pm

prsekhar13 wrote: But i just want to export file into my local machine.
Is it possible with vsql?
It is not. You can either copy the file or use an application to extract the data.
Checkout vertica.tips for more Vertica resources.

scutter
Master
Master
Posts: 302
Joined: Tue Aug 07, 2012 2:15 am

Re: Export query result to csv file

Post by scutter » Fri Nov 14, 2014 8:56 pm

You could install a vsql client on your local machine and exeute vsql from there.
Sharon Cutter
Vertica Consultant, Zazz Technologies LLC

prsekhar13
Newbie
Newbie
Posts: 6
Joined: Wed Feb 26, 2014 9:05 am

Re: Export query result to csv file

Post by prsekhar13 » Sat Nov 15, 2014 7:34 am

Thank u very much for your reply .It will be useful for me.

NorbertKrupa
GURU
GURU
Posts: 527
Joined: Tue Oct 22, 2013 9:36 pm
Location: Chicago, IL
Contact:

Re: Export query result to csv file

Post by NorbertKrupa » Sat Nov 15, 2014 4:09 pm

scutter wrote:You could install a vsql client on your local machine and exeute vsql from there.
Would have never thought of that. Has to be a Linux machine though?
Checkout vertica.tips for more Vertica resources.

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Export query result to csv file

Post by JimKnicely » Sat Nov 15, 2014 4:50 pm

Whenever you install the Vertica Windows client package, vsql is also installed!

Example:

Code: Select all

C:\Users\knicely>vsql -U dbadmin -h 10.10.10.1 -c "select * from dual;" -o e:\dual.txt

C:\Users\knicely>more e:\dual.txt
 dummy
-------
 X
(1 row)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

scutter
Master
Master
Posts: 302
Joined: Tue Aug 07, 2012 2:15 am

Re: Export query result to csv file

Post by scutter » Sun Nov 16, 2014 2:40 am

There’s also a vsql client for osx.
Sharon Cutter
Vertica Consultant, Zazz Technologies LLC

Post Reply

Return to “New to Vertica SQL”