stax_open()

Description:

Create connection to the Cassandra database.

Syntax:

stax_open(nodes[:port][,keyspace][,user:pwd][,compressor][,version:verX][,clusterName:nameX][,queryOptions:optionX]) 

Note:

It is an external library function. The username and password are not required if the Cassandra database is started under the PasswordAuthenticator mode; but required if the Cassandra database is started under the authorizer: AllowAllAuthorizer mode.Use keyspace.table format in a CQL query when parameter keyspace is absent.

Parameters:

nodes

The to-be-connected database’s IP address

port

Port number; can be omitted

user:pwd

User name and password; can be omitted

keyspace

The keyspace name; can be omitted

compressor

A compression algorithm, which is LZ4, Snappy and none; default is none

version

Protocol version information; can be absent

queryOptions

A query option, which includes ANY, ONE, TOW, THREE, ALL and QUORUM; there are details in Cssandra documentation

Return value:

The database connection

Example:

 

A

 

1

=stax_open("127.0.0.1":9042, "mycasdb","cassandra":"cassandra")

Cassandra database connection under the authorizer: AllowAllAuthorizer mode

2

=stax_open("127.0.0.1":9042, "mycasdb")

Cassandra database connection under the PasswordAuthenticator mode

3

=stax_open("127.0.0.1":9042, "mycasdb","cassandra":"cassandra":"lz4")

Set compression algorithm as LZ4

4

=stax_open("127.0.0.1":9042)

Parameter keyspace is absent

5

=stax_query(A1,"select * from mycasdb.user")

Use keyspace.table format in the CQL query