%% Insert Table Record Using MATLAB® Interface to SQLite
% Create a table in a new SQLite database file, and then insert a new row of data into the table.
% Create the SQLite connection conn to the new SQLite database file tutorial.db. Specify the file name in the current folder.

dbfile = fullfile(pwd,'tutorial.db');

conn = sqlite(dbfile,'create');

% Create the table inventoryTable using exec.
%

createInventoryTable = ['create table inventoryTable ' ...
    '(productNumber NUMERIC, Quantity NUMERIC, ' ...
    'Price NUMERIC, inventoryDate VARCHAR)'];

exec(conn,createInventoryTable)

% inventoryTable is an empty table in tutorial.db.
% Insert a row of data into inventoryTable.
%

colnames = {'productNumber','Quantity','Price','inventoryDate'};

insert(conn,'inventoryTable',colnames, ...
    {20,150,50.00,'11/3/2015 2:24:33 AM'})

%
% Close the SQLite connection.

close(conn)