Sqlite Toolkit - @octave_sqlite/sqlwrite


: sqlwrite (db, tablename, data)
: sqlwrite (db, tablename, data, columntypes)
: sqlwrite (db, tablename, data, propertyname, propertyvalue …)

Insert rows of data into a table.

Insert rows of data into a sqlite database table. If the table does not exist it will be created, using the ColumnType property if available otherwise, the type of input data will be used to determine field types.

Inputs

db

Previously created octave_sqlite object

tablename

Name of table to write data to

data

Table containing data to write to the database. Variables names are expected to match the database.

columntypes

Optional cell array of same size as data used if table must be created. The column types may also be passed in using the propertyname, propertyvalue syntax.

propertyname, propertyvalue

property name/value pairs where known properties are:

ColumnType

Optional cell array of same size as the data that may be used if the table is created as part of the write operation.

Outputs

None

Examples

Create a database table and insert a row

 
 # create sql connection
 db = sqlite("mytest.db", "create");
 # create table (if it does not exist) and then insert 2 rows
 t = dbtable([1;2],['Name1';'Name2'], 'VariableNames', {'Id','Name'});
 # insert table data
 sqlwrite(db, "Test", t, 'ColumnType', {'numeric', 'text'});
 
 

See also: sqlite, execute.