lv-client
LiveView Client — A client for querying a LiveView Server from the system command prompt.
SYNOPSIS
lv-client [-u uri][-c][-w waitTimeMS] "
command
" [help]
lv-client --version
lv-client help
LV> command [--help];
DESCRIPTION
lv-client is the command-line client for creating simple queries against a running LiveView server. You can use lv-client commands in scripts, or directly from a system command prompt. Commands that are supported for use at the command prompt are noted with (command-line support).
Without arguments, lv-client enters an interactive shell mode, showing the prompt LV>. All commands entered in the interactive client must end with a semicolon (;).
OPTIONS
-
-u
uri
-
Specifies the URI for the LiveView Server instance to communicate with, using the
lv://
protocol, orlvs://
if SSL authentication is enabled on the server. If a URI is provided with-u
, lv-client connects to the specified LiveView Server immediately on startup, or quits if unsuccessful. When connecting to a server on which LiveView authentication is enabled, place a valid user name and password, separated by a colon and appended with an at-sign, just before the server name. For example:lv://
lvuser:lvpassword
@localhost:10080 lv://lvuser:lvpassword
@remote-lv.example.com:10080 -
-p
TCP-port
-
Specifies the port number on
localhost
of the LiveView server instance to communicate with. This is a shortcut alternative to specifying the full URI with-u
in cases where the server is running onlocalhost
but on a port other than the default 10080. - -c
-
Returns query output in comma-separated value (CSV) format.
-
-w
waitTimeMS
-
Specifies a wait time
waitTimeMS
in milliseconds for the command to continually attempt to connect to LiveView Server before abandoning the connect attempt. - --version
-
Shows the version of the LiveView Java Client library used to build lv-client.
COMMANDS
-
addalertaction
ruleID
-
Adds an alert action to the
ruleID
provided. The available actions are:delete publish email -
addalertrule
tableName
predicate
--message "messageText
" --name "alertName
" -
Adds an alert rule with no actions.
-
close
queryid
-
Closes the specified query.
-
connect [
uri
] -
Closes any existing connection and connects to the specified LiveView Server instance, or to the default server if no
uri
argument is provided. With no argument, the connect command connects to the default LiveView Server URI,lv://localhost:10080
. When connecting to a server on which LiveView authentication is enabled, place a valid user name and password, separated by a colon and appended with an at-sign, just before the server name. For example:lv://
lvuser:lvpassword
@localhost:10080 lv://lvuser:lvpassword
@remote-lv.example.com:10080 - connstat
-
Retrieves information about the current LiveView Server connection (command-line support).
- createtable
-
Creates a new LiveView table of the specified type and adds it to the project currently running on LiveView Server. Supports the following options:
-
--name
tablename
, --schema (schema-def
) -
where
schema-def
is a parenthesized, comma-separated list of field name and data type pairs, such as(stock string, price double)
-
--keys
keystring
-
where
keystring
is is comma-separated, no-spaces list of primary key field names, optionally followed by a semicolon and a comma-separated, no-spaces list of secondary key field names. Example:--keys stock,transid;price
-
[--description
description
], [--aggbasetablebase-table-name
], [--aggqueryquerystring
] -
To create an aggregation table specify both
--agg*
options, with the name of the base Data Table to aggregate from, and wherequerystring
is a parenthesized projection string, such as(select stock, sum(price) as totalPrice from basetable group by stock)
-
--name
-
delete [from]
TableName
[predicate-clause
] -
Deletes rows that match a query predicate that begins with WHERE or WHEN. With no predicate clause specified, this command deletes all rows from the specified table.
Caution
Deleted data cannot be recovered, so use this command with care.
-
disablerules [
ruleid
] -
Disables all or a specified of alert rules. To specify a rule, use the rule ID number (command-line support).
-
droptable
tablename
-
Drops the specified Data Table and any dependent tables such as Aggregation or Preprocessor tables.
-
enablerules [
ruleid
] -
Enables all or a specified set of alert rules. To specify a rule, use it rule ID number (command-line support).
- help
-
Displays available commands (command-line support). The --help option also provides command-level help for every option of the
command
argument. -
listen
queryid
-
Listens to a running live query. Press x+enter to stop listening.
-
listrules [
ruleid
] -
Lists all or specified alert rules. To specify a rule, use the rule id number (command-line support).
-
listtable [
TableName
], listtables [TableName
] -
Lists tables available for querying. If you give the command a table name as a argument, it returns the field names and associated data types of the specified table (command-line support).
- live
-
Creates a live query (command-line support).
- livestat
-
Lists status of current live queries.
-
print
queryid
-
Prints current results of a live query.
-
publish
TableName
[--delete[bufferSize [flushIntervalMS]]
] -
Reads CSV data from standard input and publishes to the specified table (command-line support).
- quit
-
Quits the interactive client.
- select
-
Runs a snapshot query. The select command uses the syntax of the SQL SELECT statement (command-line support).
-
killquery [
sessionid queryid
] | [--wherepredicate-clause
] -
Kills the query having the specified combination of session ID and query ID. Or, if used with a
predicate-clause
, kills all queries currently listed in the LVSessionQueries table that satisfy the provided predicate against LVSessionQueries. -
killsession [
sessionid
] | [--wherepredicate-clause
] -
Kills the session with the specified session ID. Or, if used with the
predicate-clause
, kills all the sessions from the LVSessions table that satisfy the predicate against LVSessions. -
killpublisher [
sessionid publisherid
] | [--wherepredicate-clause
] -
kills the publisher having the specified combination of session ID and publisher ID. Or, if used with a
predicate-clause
, kills all publishers from the LVSessionPublishers table that satisfy the predicate against LVSessionPublishers. - shutdown
-
Shuts down LiveView Server (command-line support).
-
starttable
tablename
-
Starts or restarts the specified Data Table and all dependent tables.
- version
-
Displays the version of the connected LiveView Server (command-line support).
EXAMPLES
This example runs simple queries against the Hello LiveView sample project that was
loaded into the StreamBase Studio workspace in the project folder sample_lv-helloliveview
. All commands are run from the StreamBase
Command Prompt
-
To run the Hello LiveView sample for the Windows username sbuser, use the following command. (This single command is shown on two lines for clarity.)
lv-server run "C:\Users\
sbuser
\Documents\ StreamBase Studio 7.5 Workspace\sample_lv-helloliveview" -
Use the command line to list the tables in the running LiveView application:
lv-client listtables
-
Connect to the default URI and start the lv-client interactive shell:
lv-client -u lv://localhost:10080
-
Create a snapshot query that returns all rows from the
ItemsSales
table wherelastSoldPrice
is greater than 10 andquantityRemaining
is less than 20:SELECT * FROM ItemsSales WHERE lastSoldPrice > 10 AND quantityRemaining < 20;
-
Exit the interactive client and run the same query from the system command line:
quit; lv-client -u lv://localhost:10080 "SELECT * FROM ItemsSales WHERE lastSoldPrice > 10 AND quantityRemaining < 20;"
-
The next two lines run at a StreamBase Command Prompt on Windows start LiveView Server running the Hello LiveView sample, waits three minutes for the server to come up (180,000 milliseconds), then checks the connection status.
start /min lv-server run "C:\Users\
sbuser
\Documents\ StreamBase Studio 7.5 Workspace\sample_lv-helloliveview" lv-client -w 180000 connstatThe following two lines are the same, but run from a Linux or OS X terminal:
lv-server run "/Users/
sbuser
/Documents/ Streambase Studio 7.5 Workspace\sample_lv-helloliveview" lv-client -w 180000 connstat