class swat.cas.connection.CAS(hostname=None, port=None, username=None, password=None, session=None, locale=None, nworkers=None, name=None, authinfo=None, protocol=None, path=None, ssl_ca_list=None, authcode=None, pkce=False, **kwargs)

Bases: object

Create a connection to a CAS server.

hostnamestring or list-of-strings, optional

Host or URL to connect to. This parameter can also be specified by a CAS_URL or CAS_HOST environment variable.

portint or long, optional

Port number. If not specified, the value will come from the cas.port option or CAS_PORT environment variable. If a URL is specified in the first parameter, that port number will be used.

usernamestring, optional

Name of user on CAS host. This parameter can also be specified in a CAS_USER environment variable.

passwordstring, optional

Password of user on CAS host or OAuth token. If an OAuth token is specified, the username parameter should be None. This parameter can also be specified in a CAS_PASSWORD or CAS_TOKEN environment variable.

sessionstring, optional

ID of existing session to reconnect to.

localestring, optional

Name of locale used for the session.

namestring, optional

User-definable name for the session.

nworkersint or long, optional

Number of worker nodes to use.

authinfostring or list-of-strings, optional

The filename or list of filenames of authinfo/netrc files used for authentication.

protocolstring, optional

The protocol to use for communicating with the server. This protocol must match the protocol spoken by the specified server port. If the first parameter is a URL, that protocol will be used.

pathstring, optional

Base path of URL when using the REST protocol.

ssl_ca_liststring, optional

The path to the SSL certificates for the CAS server.

authcodestring, optional

Authorization code from SASLogon used to retrieve an OAuth token.

pkceboolean, optional

Use Proof Key for Code Exchange to obtain the Authorization code

**kwargsany, optional

Arbitrary keyword arguments used for internal purposes only.

CAS object

When a connection can not be established.


To create a connection to a CAS host, you simply supply a hostname (or list of hostnames), a port number, and user credentials. Here is an example specifying a single hostname, and username and password as strings.

>>> conn = swat.CAS('mycashost.com', 5570, 'username', 'password')

If you use an authinfo file and it is in your home directory, you don’t have to specify any username or password. You can override the authinfo file location with the authinfo= parameter. This form also works for Kerberos authentication.

>>> conn = swat.CAS('mycashost.com', 5570)

If you specify multiple hostnames, it will connect to the first available server in the list.

>>> conn = swat.CAS(['mycashost1.com', 'mycashost2.com', 'mycashost3.com'],
                    5570, 'username', 'password')

URLs can also be used for both binary and REST protocols. Notice that you need to specify the username= and password= keywords since the port number is skipped.

>>> conn = swat.CAS('cas://mycashost1.com:5570',
...                 username='username', password='password')
>>> conn = swat.CAS('http://mycashost1.com:80',
...                 username='username', password='password')

To connect to an existing CAS session, you specify the session identifier.

>>> conn = swat.CAS('mycashost.com', 5570,
...                 session='ABCDEF12-ABCD-EFG1-2345-ABCDEF123456')

If you wish to change the locale used on the server, you can use the locale= option.

>>> conn = swat.CAS('mycashost.com', 5570, locale='es_US')

To limit the number of worker nodes in a grid, you use the nworkers= parameter.

>>> conn = swat.CAS('mycashost.com', 5570, nworkers=4)
__init__(self, hostname=None, port=None, username=None, password=None, session=None, locale=None, nworkers=None, name=None, authinfo=None, protocol=None, path=None, ssl_ca_list=None, authcode=None, pkce=False, **kwargs)

Initialize self. See help(type(self)) for accurate signature.


CASTable(self, name, \*\*kwargs)


Create a SASFormatter instance

__init__(self[, hostname, port, username, …])

Initialize self.

add_results_hook(self, name, func)

Add a post-processing function for results

close(self[, close_session])

Close the CAS connection


Create a copy of the connection

del_results_hook(self, name, func)

Delete a post-processing function for an action

del_results_hooks(self, name)

Delete all post-processing functions for an action

fork(self[, num])

Create multiple copies of a connection

get_action(self, name)

Get the CAS action instance for the given action name

get_action_class(self, name)

Get the CAS action class for the given action name


Return the list of action classes

get_actionset(self, name)

Get the CAS action set instance for the given action set name


Return the list of actionset classes

has_action(self, name)

Does the given action name exist?

has_actionset(self, name)

Does the given actionset name exist?

invoke(self, _name_, \*\*kwargs)

Call an action on the server

json_normalize(self, data[, casout])

“Normalize” semi-structured JSON data into a flat table and upload to a CAS table

load_path(self[, path, readahead, …])

Load a path from a CASLib

path_to_caslib(self, path[, name])

Return a caslib name for a given path

read_clipboard(self[, casout])

Read text from clipboard and pass to read_table()

read_csv(self, filepath_or_buffer[, casout])

Read CSV file into a CAS table

read_excel(self, io[, casout])

Read an Excel table into a CAS table

read_frame(self, dframe[, casout])

Convert DataFrame to CAS table

read_fwf(self, filepath_or_buffer[, casout])

Read a table of fixed-width formatted lines into a CAS table

read_gbq(self, query[, casout])

Load data from a Google BigQuery into a CAS table

read_hdf(self, path_or_buf[, casout])

Read from the HDF store and create a CAS table

read_html(self, io[, casout])

Read HTML tables into a list of CASTable objects

read_json(self[, path_or_buf, casout])

Read a JSON string into a CAS table

read_pickle(self, path[, casout])

Load pickled pandas object from the specified path

read_sas(self, filepath_or_buffer[, casout])

Read SAS files stored as XPORT or SAS7BDAT into a CAS table

read_sql(self, sql, con[, casout])

Read SQL query or database table into a CAS table

read_sql_query(self, sql, con[, casout])

Read SQL query table into a CAS table

read_sql_table(self, table_name, con[, casout])

Read SQL database table into a CAS table

read_stata(self, filepath_or_buffer[, casout])

Read Stata file into a CAS table

read_table(self, filepath_or_buffer[, casout])

Read general delimited file into a CAS table

retrieve(self, _name_, \*\*kwargs)

Call the action and aggregate the results

session_context(self, \*args, \*\*kwargs)

Create a context of session options


End the session and close the CAS connection

upload(self, data[, importoptions, casout, …])

Upload data from a local file into a CAS table

upload_file(self, data[, importoptions, casout])

Upload a client-side data file to CAS and parse it into a CAS table

upload_frame(self, data[, importoptions, casout])

Upload a client-side data file to CAS and parse it into a CAS table