Configuring a cqlshrc file

A cqlshrc file contains CQL shell session settings that are used when the CQL shell starts.


The location of the cassandra.yaml file depends on the type of installation:

Package installations
Installer-Services installations


Tarball installations
Installer-No Services installations

  • The cassandra.yaml file is located in the installation_location/conf directory.

A cqlshrc file contains CQL shell session settings that are used when the CQL shell starts. If you place a cqlshrc file in the ~/.cassandra directory on a local computer, that file is used by default. You can also specify the directory that the cqlshrc file is in using the --cqlshrc option. Place only one cqlshrc file in a directory.

Do not confuse the cqlshrc file with the --cqlshrc option. The first is a file containing CQL session settings, the second is an option that specifies the directory where the cqlshrc file is located.

You can configure the following options:


cqlsh --cqlshrc="~/directory_name"
Note: Tilde (~) expands to the user's home directory; you can also specify the absolute path, for example /Users/jdoe/cqlshprofiles/west.
Table 1. Legend
Syntax conventions Description
UPPERCASE Literal keyword.
Lowercase Not literal.
Italics Variable value. Replace with a user-defined value.
[] Optional. Square brackets ( [] ) surround optional command arguments. Do not type the square brackets.
( ) Group. Parentheses ( ( ) ) identify a group to choose from. Do not type the parentheses.
| Or. A vertical bar ( | ) separates alternative elements. Type any one of the elements. Do not type the vertical bar.
... Repeatable. An ellipsis ( ... ) indicates that you can repeat the syntax element as often as required.
'Literal string' Single quotation ( ' ) marks must surround literal strings in CQL statements. Use single quotation marks to preserve upper case.
{ key : value } Map collection. Braces ( { } ) enclose map collections or key value pairs. A colon separates the key and the value.
<datatype1,datatype2> Set, list, map, or tuple. Angle brackets ( < > ) enclose data types in a set, list, map, or tuple. Separate the data types with a comma.
cql_statement; End CQL statement. A semicolon ( ; ) terminates all CQL statements.
[--] Separate the command line options from the command arguments with two hyphens ( -- ). This syntax is useful when arguments might be mistaken for command line options.
' <schema> ... </schema> ' Search CQL only: Single quotation marks ( ' ) surround an entire XML schema declaration.
@xml_entity='xml_entity_type' Search CQL only: Identify the entity and literal value to overwrite the XML element in the schema and solrConfig files.

Using a sample cqlshrc file

A sample file is installed with DataStax Enterprise (DSE) cqlshrc sample files. These files contain all the available settings. Some settings are commented out using a single semi-colon.

DSE provides sample cqlshrc files:
  • cqlshrc.sample: Contains all available settings.
  • cqlshrc.sample.kerberos: Contains settings related to using Kerberos authentication for the CQL shell connection.
  • cqlshrc.sample.ssl: Contains settings related to using SSL for the CQL shell for the connection.
  • cqlshrc.sample.kerberos_ssl: Contains settings related to using SSL and Kerberos authentication for the CQL shell connection.
The location of these files depend on the type of installation:
  • Package and Installer-Services installations: /etc/dse/cassandra
  • Tarball and Installer-No Services installations: install_location/resources/cassandra/conf

Make changes as appropriate for your environment.

To use the sample file:
  1. Copy the cqlshrc.sample file to the ~/.cassandra/ directory.
  2. Rename the file to cqlshrc. The file should be located in ~/.cassandra/cqlshrc.
    Note: If cqlsh finds the .cqlshrc file located in the home directory, cqlsh moves the file to ~/.cassandra/cqlshrc upon its next invocation and outputs a message that the file moved.
  3. Remove the semi-colon to uncomment an option (options must be in brackets) and its corresponding settings. The example below uncomments [copy] and header = false to import all CSV without a header row:
    ;; Options that are common to both COPY TO and COPY FROM
    ;; The string placeholder for null values
    ; nullval = null
    ;; For COPY TO, controls whether the first line in the CSV output file will
    ;; contain the column names.  For COPY FROM, specifies whether the first
    ;; line in the CSV file contains column names.
    header = false
  4. Restart the CQL shell.

Automatically logging in and selecting a keyspace

Set up credentials to automatically log in when CQL shell starts and optionally choose a keyspace.

Note: Only set a user name and password for hosts that use internal authentication, see Encrypting with SSL.
Log in account name.
Log in password.
Optional. Opens the specified keyspace. Equivalent to issuing a USE keyspace command immediately after starting cqlsh. (Does not require internal authentication.)

Disabling logging

Disables saving history to disk for current execution when CQL shell starts.

If set to TRUE, cqlsh logging is disabled. Default: FALSE

Changing the CQL shell display

The cqlsh console display and COPY TO date parsing settings.

Shows query results with color.
on - color
off - no color
Configure the format of timestamps using Python strftime syntax.
Display timestamps in Etc/UTC.
float_precision, double_precision
Sets the number of digits displayed after the decimal point for single and double precision numbers.
Note: Increasing this to large numbers can result in unusual values.
Set the key for automatic completion of a cqlsh shell entry. Default is the tab key.
The encoding used for characters. The default is UTF8.

Forcing the CQL version

Use the specified version of CQL only.

Only use the specified version of CQL.

Connecting to a CQL host

Specify the host and connection details for the CQL shell session.

The host for the cqlsh connection.
The connection port. Default: 9042 (native protocol).
Always connect using SSL. Default: false.
Configures timeout in seconds when opening new connections.
Configures the request timeout in seconds for executing queries. Set the number of seconds of inactivity.

Limiting the field size

Set to a particular field size, such as field_size_limit = 1000000000.

Setting tracing timeout

Specify the wait time for tracing.

The maximum number of seconds to wait for a trace to complete.

Configuring SSL

Specify connection SSL settings.

Note: For more information, see Using cqlsh with SSL encryption.
The path to the DSE certificate.
Optional. Default: true.
Must be provided when require_client_auth=true in cassandra.yaml.
Must be provided when require_client_auth=true in cassandra.yaml.

Overriding SSL local settings

Overrides default certfiles in the [ssl] section. Create an entry for each remote host.

Specify the IP address or remote host name and path to the certificate file on your local system.

Setting common COPY TO and COPY FROM options

Settings common to both COPY TO and COPY FROM.
BOOLSTYLE       = True,False
CONFIGFILE      = /home/
DELIMITER       = |
ESCAPE          = `
HEADER          = true
NULL            = NULL
QUOTE           = "
RATEFILE        = /home/copyrate.log
SKIPCOLS        = firstname
SKIPROWS        = 6
Boolean indicators for true and false. The values are case-insensitive. For example, yes,no and YES,NO are the same.

Default: True,False

Specify a directory that contains the cqlshrc configuration file.
Note: Command line options always override the cqlshrc file.
Time format for reading or writing CSV time data. The timestamp uses the strftime format. If not set, the default value is set to the datetimeformat value in the cqlshrc file.

Default: %Y-%m-%d %H:%M:%S%z

Decimal value separator.

Default: . (period)

Field separator.

Default: , (comma)

Single character that escapes literal uses of the QUOTE character.

Default: \ (backslash)

  • true - first row contains headers (column names)
  • false - first row does not have headers

Default: false

Maximum number of attempts for errors.

Default: 5

Value used when no value is in the field.

Default: <empty>

Number of worker processes. Maximum value is 16.

Default: -1

Encloses field values.

Default: " (double quotation mark)

Frequency with which status is displayed in seconds.

Default: 0.25

Print output statistics to this file.
Name of column to skip.
Number of rows starting from the first row of data to skip.
Separator for thousands digit groups.

Setting COPY TO specific options

Under the [copy-to] section set any of the export options.
Minimum token string for exporting data.
Number of digits to display after the decimal point for CQL double precision values.

Default: 12

Output string type.

Default: UTF8

Maximum token string for exporting data.
File to store all rows that are not imported. If no value is set, the information is stored in import_ks_table.err where ks is the keyspace and table is the table name.
Number of digits to display after the decimal point for CQL float (single precision) values.

Default: 5

Maximum size of the output file, measured in number of lines. When set, the output file is split into segment when the value is exceeded. Use -1 for no maximum.

Default: -1

Maximum number of requests each worker can process in parallel.

Default: 6

Page size for fetching results.

Default: 1000

Page timeout for fetching results.

Default: 10

Time to live in seconds. By default, data will not expire.

Default: 3600

Setting COPY FROM specific options

Under the [copy-from] section set any of the import options.

Chunk size passed to worker processes.

Default: 1000

Approximate ingest rate in rows per second. Must be greater than the chunk size.

Default: 100000

Maximum size of an import batch.

Default: 20

Maximum global number of insert errors. Use -1for no maximum.

Default: -1

Maximum global number of parsing errors. Use -1 for no maximum.

Default: -1

Maximum number of rows. Use -1 for no maximum.

Default: -1

Minimum size of an import batch.

Default: 2

Setting table specific COPY TO/FROM options

Use these options to configure table specific settings; create a new entry for each table, for example to set the chunk size for cyclist names and rank:
chunksize = 1000
chunksize = 10000
Chunk size passed to worker processes.
Approximate ingest rate in rows per second. Must be greater than the chunk size.
Page timeout for fetching results.