Password option for \c command in vsql?

Moderator: NorbertKrupa

Post Reply
billykopecki
Beginner
Beginner
Posts: 42
Joined: Thu Apr 19, 2012 9:03 pm

Password option for \c command in vsql?

Post by billykopecki » Mon Sep 23, 2013 8:45 pm

hello,

I use the \c (connect) command in vsql to connect as a different user. I can only pass it the database name and user name. Is it possible to add the password to the command so that I don't have to type it when asked?

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Password option for \c command in vsql?

Post by id10t » Mon Sep 23, 2013 9:18 pm

Hi!

From vsql? No. Outside vsql, in shell(bash/zsh/csh/ksh, whatever), you can by using aliases or write an execution wrapper.

Alias:
http://www.cyberciti.biz/tips/bash-alia ... -unix.html
http://www.linfo.org/alias.html

Wrapper example:
(I will show functions, but scripts are better. /opt/vertica/scripts/exec_vsql.sh is example for wrapper)

Code: Select all

daniel@synapse:/tmp$ function vsql_fred { /opt/vertica/bin/vsql -U Fred "${1}" "${2}"; }
daniel@synapse:/tmp$ vsql_fred -c "\echo :USER"
Fred
daniel@synapse:/tmp$ vsql -c "\echo :USER"
daniel
You can save function in "~/.bashrc" file for permanent usage (because function will lost when terminal will closed) and use in two "vsql" callers: for "dbadmin" and other user.

billykopecki
Beginner
Beginner
Posts: 42
Joined: Thu Apr 19, 2012 9:03 pm

Re: Password option for \c command in vsql?

Post by billykopecki » Tue Sep 24, 2013 9:15 pm

Thanks for you reply, sKwa. I'll try this out.

Post Reply

Return to “vSQL”