%% Import Data Using Multiple Partition Key Values
% Using a Cassandra® database connection, import data from a Cassandra database table into MATLAB®. Use the values of two partition keys in the database table to import data. 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_name database table by using the Cassandra database connection. This database table has the first_name and last_name partition keys. Specify the first and last names of two employees as values of the partition keys to import data for those two employees.

keyspace = "employeedata";
tablename = "employees_by_name";
keyValue1 = ["Christopher","Alexander"];
keyValue2 = ["Olsen","Hunold"];
results = partitionRead(conn,keyspace,tablename,keyValue1,keyValue2);

%
% Display the returned employee data for the two employees.

results

% results is a table that contains these variables:
% first_name — First name
% last_name — Last name
% hire_date — Hire date
% employee_id — Employee identifier
% commission_pct — Commission percentage
% department_id — Department identifier
% email — Email address
% job_id — Job identifier
% 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.