Skip to content

Commit

Permalink
[MultiDB] sonic-db-cli should support EVAL operation, app script use … (
Browse files Browse the repository at this point in the history
sonic-net#58)

* [MultiDB] sonic-db-cli should support EVAL operation, app script use it in this way
* unify client.execute_command
  • Loading branch information
dzhangalibaba authored and qiluo-msft committed Dec 18, 2019
1 parent 022d8fb commit ccc1307
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/swsssdk/scripts/sonic-db-cli
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import swsssdk

argc = len(sys.argv)
if argc == 2 and sys.argv[1] == '-h':
print "Example 1: sonic-db-cli CONFIG_DB keys *"
print "Example 2: sonic-db-cli APPL_DB HGETALL VLAN_TABLE:Vlan10"
print "Example 3: sonic-db-cli APPL_DB HGET VLAN_TABLE:Vlan10 mtu"
print("""
Example 1: sonic-db-cli CONFIG_DB keys *
Example 2: sonic-db-cli APPL_DB HGETALL VLAN_TABLE:Vlan10
Example 3: sonic-db-cli APPL_DB HGET VLAN_TABLE:Vlan10 mtu
Example 4: sonic-db-cli APPL_DB EVAL "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 k1 k2 v1 v2
""")
elif argc < 3:
msg = "'Usage: sonic-db-cli <db_name> <cmd> [arg [arg ...]]'. See 'sonic-db-cli -h' for detail examples."
print >> sys.stderr, msg
Expand All @@ -20,4 +23,5 @@ else:
print >> sys.stderr, msg
else:
client = dbconn.get_redis_client(dbname)
print client.execute_command(" ".join(sys.argv[2:]))
args = sys.argv[2:]
print client.execute_command(*args)

0 comments on commit ccc1307

Please sign in to comment.