Next: , Previous: , Up: Top   [Index]


1 Overview

1.1 Installation

Before installing the caosdb library in Octave, you first need to install libcaosdb with Conan. Typically, it should be sufficient to download the sources from https://gitlab.com/caosdb/caosdb-cpplib and execute make conan.

With pkg install

Then get the Octave package for the caosdb library or its source code and install it from within Octave with pkg install caosdb.tar.gz; (if you downloaded the package) or pkg install /path/to/source/dir;. To make the library contents available to your code, activate it with pkg load caosdb;

Manual installation

For other environments which lack a package management system, such as Matlab, you can go into the src/ directory and call ./configure there, followed by make install. You will then have to copy the resulting files to a place which is in your search path so that the .m and .mex files can be found. Once the files are in your search path, they are immediately available to your code.

Configuration

Since the Octave CaosDB library uses libcaosdb, the configuration is handled by libcaosdb as well. In practice this means that there should be a configuration file, either in the current directory, your home directory or at a location specified by the CAOSDB_CLIENT_CONFIGURATION environment variable. More information about the configuration is available at the libcaosdb documentation.

1.2 First steps

Starting off with CaosDB in Octave is easy:

%% Set up the library
pkg load caosdb;   % Not necessary if you manually put the CaosDB files into your search path.
c = Caosdb();      % Uses the default connection as defined in the configuration.
c.info()           % Output some diagnostic message.

%% Execute a simple query
my_query = 'FIND Record MusicalInstrument WITH price > 2000';
results = c.query(my_query);
disp(['Found ' num2str(numel(results)) ' results']);
if numel(results) > 0
  disp(results{1});
end

You can create and modify CaosDB entities much in the same way as with libcaosdb, so please refer to the documentation available there for details. These operations, and also inserting, updating and deleting entities are straight-forward in Octave:

%% Continuing from the code above...
my_instrument = Entity();       % Create new entity, set role and name
my_instrument.role = 'RECORD';
my_instrument.name = 'My new theremin';

% set parent
instrument_id = c.query('FIND RecordType MusicalInstrument'){1}.id;
instrument = Parent();
instrument.id = instrument_id;

my_instrument.set_parents({instrument});

% set property
price_id = c.query('FIND Property price'){1}.id;
price = Property();
price.id = price_id;
price.set_datatype('DOUBLE');   % Datatype must be set in order to set a value.
price.value = 2300;             % Integer values would need to be cast to int64.

my_instrument.set_properties({price});

%% Insert the instrument Record.
insert_result = c.insert({my_instrument});

disp(insert_result{1}.id);

1.3 Further reading

For more information, you may want to read up on


Next: , Previous: , Up: Top   [Index]