swat.CAS¶
-
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, **kwargs)¶ Bases: object
Create a connection to a CAS server.
Parameters: - hostname : string or list-of-strings, optional
Host to connect to. If not specified, the value will come from the cas.hostname option or CASHOST environment variable.
- port : int or long, optional
Port number. If not specified, the value will come from the cas.port option or CASPORT environment variable.
- username : string, optional
Name of user on CAS host.
- password : string, optional
Password of user on CAS host.
- session : string, optional
ID of existing session to reconnect to.
- locale : string, optional
Name of locale used for the session.
- name : string, optional
User-definable name for the session.
- nworkers : int or long, optional
Number of worker nodes to use.
- authinfo : string or list-of-strings, optional
The filename or list of filenames of authinfo/netrc files used for authentication.
- protocol : string, optional
The protocol to use for communicating with the server. This protocol must match the protocol spoken by the specified server port. If not specified, the value will come from the cas.protocol option or CASPROTOCOL environment variable.
- **kwargs : any, optional
Arbitrary keyword arguments used for internal purposes only.
Returns: - CAS object
Raises: - IOError
When a connection can not be established.
Examples
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', 12345, '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', 12345)
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'], 12345, 'username', 'password')
To connect to an existing CAS session, you specify the session identifier.
>>> conn = swat.CAS('mycashost.com', 12345, 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', 12345, locale='es_US')
To limit the number of worker nodes in a grid, you use the nworkers= parameter.
>>> conn = swat.CAS('mycashost.com', 12345, nworkers=4)
-
__init__
(hostname=None, port=None, username=None, password=None, session=None, locale=None, nworkers=None, name=None, authinfo=None, protocol=None, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
CASTable(name, **kwargs) SASFormatter() Create a SASFormatter instance __init__([hostname, port, username, …]) Initialize self. add_results_hook(name, func) Add a post-processing function for results close() Close the CAS connection copy() Create a copy of the connection del_results_hook(name, func) Delete a post-processing function for an action del_results_hooks(name) Delete all post-processing functions for an action fork([num]) Create multiple copies of a connection get_action(name) Get the CAS action instance for the given action name get_action_class(name) Get the CAS action class for the given action name get_action_names() Return the list of action classes get_actionset(name) Get the CAS action set instance for the given action set name get_actionset_names() Return the list of actionset classes has_action(name) Does the given action name exist? has_actionset(name) Does the given actionset name exist? invoke(_name_, **kwargs) Call an action on the server json_normalize(data[, casout]) “Normalize” semi-structured JSON data into a flat table and upload to a CAS table load_path([path, readahead, importoptions, …]) Load a path from a CASLib read_clipboard([casout]) Read text from clipboard and pass to read_table() read_csv(filepath_or_buffer[, casout]) Read CSV file into a CAS table read_excel(io[, casout]) Read an Excel table into a CAS table read_frame(dframe[, casout]) Convert DataFrame to CAS table read_fwf(filepath_or_buffer[, casout]) Read a table of fixed-width formatted lines into a CAS table read_gbq(query[, casout]) Load data from a Google BigQuery into a CAS table read_hdf(path_or_buf[, casout]) Read from the HDF store and create a CAS table read_html(io[, casout]) Read HTML tables into a list of CASTable objects read_json([path_or_buf, casout]) Read a JSON string into a CAS table read_pickle(path[, casout]) Load pickled pandas object from the specified path read_sas(filepath_or_buffer[, casout]) Read SAS files stored as XPORT or SAS7BDAT into a CAS table read_sql(sql, con[, casout]) Read SQL query or database table into a CAS table read_sql_query(sql, con[, casout]) Read SQL query table into a CAS table read_sql_table(table_name, con[, casout]) Read SQL database table into a CAS table read_stata(filepath_or_buffer[, casout]) Read Stata file into a CAS table read_table(filepath_or_buffer[, casout]) Read general delimited file into a CAS table retrieve(_name_, **kwargs) Call the action and aggregate the results session_context(*args, **kwargs) Create a context of session options terminate() End the session and close the CAS connection upload(data[, importoptions, casout]) Upload data from a local file into a CAS table upload_file(data[, importoptions, casout]) Upload a client-side data file to CAS and parse it into a CAS table upload_frame(data[, importoptions, casout]) Upload a client-side data file to CAS and parse it into a CAS table