How can I use gerrit gsql \-c option?

1,584 views
Skip to first unread message

paymaster

unread,
Apr 5, 2011, 2:27:09 AM4/5/11
to Repo and Gerrit Discussion
hi
i want to control mysql.. so I use gerrit gsql
ex) ssh -p <port> <ip> gerrit gsql \-c "select * from projects;"
but it doesn't work
error message : fatal : No argument is allowd
Anybody who knows this?

Martin Fick

unread,
Apr 5, 2011, 12:00:02 PM4/5/11
to repo-d...@googlegroups.com, paymaster

I usually just do:

echo "select * from projects;" | ssh -p <port> <ip> gerrit
gsql

-Martin

Anatol Pomazau

unread,
Apr 5, 2011, 12:03:08 PM4/5/11
to paymaster, Repo and Gerrit Discussion
Hi

On Mon, Apr 4, 2011 at 11:27 PM, paymaster <baeks...@gmail.com> wrote:
hi
i want to control mysql.. so I use gerrit gsql
ex) ssh -p <port> <ip> gerrit gsql \-c "select * from projects;"

You need to use ' inside of "

 
but it doesn't work
error message : fatal : No argument is allowd
Anybody who knows this?

Here is a working example

ssh -p 29418 <SERVER> gerrit gsql --format JSON -c "'select * from accounts;'" 

paymaster

unread,
Apr 6, 2011, 2:57:16 AM4/6/11
to Repo and Gerrit Discussion
Thanks for your advice it's working ^^

Dave Castagna (Motorola Mobility)

unread,
Jul 1, 2013, 4:22:33 PM7/1/13
to repo-d...@googlegroups.com
I can't seem to make string arguments in queries work.  Any ideas?:

ssh -p 29418 <address> gerrit gsql -c "'SELECT COUNT(*) FROM accounts WHERE inactive = 'Y''"

Saša Živkov

unread,
Jul 3, 2013, 8:41:06 AM7/3/13
to Dave Castagna (Motorola Mobility), repo-d...@googlegroups.com
On Mon, Jul 1, 2013 at 10:22 PM, Dave Castagna (Motorola Mobility) <cast...@motorola.com> wrote:
I can't seem to make string arguments in queries work.  Any ideas?:

ssh -p 29418 <address> gerrit gsql -c "'SELECT COUNT(*) FROM accounts WHERE inactive = 'Y''"

This is usually tricky to get right.
But, what Martin proposed also works for your example:

$ echo "SELECT COUNT(*) FROM accounts WHERE inactive = 'Y';" | ssh -p 29418 <address> gerrit gsql




On Tuesday, April 5, 2011 1:27:09 AM UTC-5, SeongUk Baek wrote:
hi
i want to control mysql.. so I use gerrit gsql
ex) ssh -p <port> <ip> gerrit gsql \-c "select * from projects;"
but it doesn't work
error message : fatal : No argument is allowd
Anybody who knows this?
---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dave Castagna (Motorola Mobility)

unread,
Jul 3, 2013, 11:11:47 AM7/3/13
to repo-d...@googlegroups.com
Thanks.  I eventually just gave up and used a direct DB connection with a Perl script.

But I wonder if we could just have this fixed in the gsql utility so that it just takes its argument literally.



On Tuesday, April 5, 2011 1:27:09 AM UTC-5, SeongUk Baek wrote:

Björn Pedersen

unread,
Jul 3, 2013, 12:00:47 PM7/3/13
to repo-d...@googlegroups.com

It's more a shell problem then a gerrit problem:
You have to ensure the quotes end up in the gsql shell,

try:
ssh -p29418 <host> gerrit gsql -c '"select * from accounts;"'
 (first single quote ' , then double quote " )

Dave Castagna (Motorola Mobility)

unread,
Jul 3, 2013, 12:05:33 PM7/3/13
to repo-d...@googlegroups.com
That actually isn't the example I can't get to work.

This is:

      ssh -p 29418 <address> gerrit gsql -c "'SELECT COUNT(*) FROM accounts WHERE inactive = 'Y''"

Note the quoted expression in the SQL query: 'Y'  Which of course by SQL syntax must be delineated with single quotes when it gets to the SQL interpreter.

I tried EVERY combination of double and single quotes I could think of.




On Tuesday, April 5, 2011 1:27:09 AM UTC-5, SeongUk Baek wrote:

Martin Fick

unread,
Jul 3, 2013, 1:21:31 PM7/3/13
to repo-d...@googlegroups.com, Dave Castagna (Motorola Mobility)
On Wednesday, July 03, 2013 10:05:33 am Dave Castagna
(Motorola Mobility) wrote:
> That actually isn't the example I can't get to work.
>
> *This is*:
The problem is the shell eats the first set of quotes, and
then ssh eats the second set, so you need something like:

ssh -p 29418 qctquicd1 gerrit gsql -c "\"SELECT COUNT(*)
FROM accounts WHERE inactive = 'Y'\""

Because of this, you generally are better off using stdin,

-Martin

--
The Qualcomm Innovation Center, Inc. is a member of Code
Aurora Forum, hosted by The Linux Foundation

Reply all
Reply to author
Forward
0 new messages