RSQL Client (rcli)

The RSQL Client rcli is a utility program that allows you to send SQL script files to the server.

The result received from the server is printed to the terminal.

Syntax

rcli [OPTIONS] [FILE...]

rcli [OPTIONS] -Q="query_string"

Arguments

OPTIONS
available options can be printed with rcli -h.
FILE…
one or more SQL script files, which will be sent to the server.
query_string
a script text, which will be sent to the server.

Configuration File

To avoid specifying the login, password and other options each time you connect to a server, it is more convenient to specify them in a config file.

By default, the config file used by rcli program is rcli.conf. If it doesn’t exist in the current directory, it is looked up in the user’s home directory.

A model config file can be created with the following command:

rcli -config_model > ~/rcli.conf
chmod 600 ~/rcli.conf

A new config file has been created in your home directory. Only you have the permission to open and modify it. In particular, you will change the login_name and password parameters.

You can create many config files with different names, and choose between them with the -config option:

rcli -config=myconfig1.conf myscript.sql

If you want to know which config file has been read, use the -v option:

rcli -config=myconfig1.conf -v myscript.sql

If the argument of -config option is a relative path and the config file is not found at this location, it will be looked up relative to the user’s home directory.

Script File

A script file contains one or many batches.

A batch is a list of TSQL statements, sent as a whole to the server for execution.

Batches are separated with GO or EXIT commands.

If a script file contains many batches, they are sent to the server one after another.

Examples

This command prints available options:

rcli -h

Connect to the server and send a SQL script string:

rcli -U=sa -P=mypassword -S=localhost:7777 -d=mydatabase -Q="print 'Hello';"

Connect to the server and send a SQL script file:

rcli -U=sa -P=mypassword -S=localhost:7777 -d=mydatabase myscript.sql

Connect to the server and send a SQL script file.
Width is 40 characters for varchar columns, and nanoseconds are printed for time and datetime columns:

rcli -U=sa -P=mypassword -S=localhost:7777 -d=mydatabase -width=40 -fracsec=9 myscript.sql

Connect to the server with the login and password stored in ~/rcli.conf config file:

rcli myscript.sql