%% Import Data from Cassandra Database Table
% Using a Cassandra® database connection, 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 local host address. conn is a cassandra object.

contactPoints = "localhost";
conn = cassandra(contactPoints);

%
% 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 2018 The MathWorks, Inc.