%% Import Data from Cassandra Database Table
% Using the Apache Cassandra® database C++ interface, create a Cassandra database connection and import data from a Cassandra database table into MATLAB®. The Cassandra database contains a database table with employee data.
% Create a Cassandra database connection using the configured data source CassandraDataSource and a blank user name and password. The apacheCassandra function returns conn as a connection object.

datasource = "CassandraDataSource";
username = "";
password = "";
conn = apacheCassandra(datasource,username,password);

% Import employee data into MATLAB from the employeedata keyspace and the employees_by_job database table by using the Cassandra database connection.

keyspace = "employeedata";
tablename = "employees_by_job";
results = partitionRead(conn,keyspace,tablename);

% Display the first few rows of the returned employee data.

head(results)

% results is a table that contains these variables:
% job_id — Job identifier
% hire_date — Hire date
% employee_id — Employee identifier
% commission_pct — Commission percentage
% department_id — Department identifier
% email — Email address
% first_name — First name
% last_name — Last name
% manager_id — Manager identifier
% office — Office location (table that contains two variables for the building and room)
% performance_ratings — Performance ratings
% phone_number — Phone number
% salary — Salary
% Close the Cassandra database connection.

close(conn)

% Copyright 2020 The MathWorks, Inc.