dm_db_json Module

Database JSON functions.


Uses

  • module~~dm_db_json~~UsesGraph module~dm_db_json dm_db_json module~dm_db dm_db module~dm_db_json->module~dm_db module~dm_db_count dm_db_count module~dm_db_json->module~dm_db_count module~dm_db_query dm_db_query module~dm_db_json->module~dm_db_query module~dm_db_row dm_db_row module~dm_db_json->module~dm_db_row module~dm_error dm_error module~dm_db_json->module~dm_error module~dm_kind dm_kind module~dm_db_json->module~dm_kind module~dm_sql dm_sql module~dm_db_json->module~dm_sql module~dm_db->module~dm_db_query module~dm_db->module~dm_error module~dm_db->module~dm_kind iso_c_binding iso_c_binding module~dm_db->iso_c_binding module~dm_util dm_util module~dm_db->module~dm_util sqlite3 sqlite3 module~dm_db->sqlite3 module~dm_db_count->module~dm_db module~dm_db_count->module~dm_error module~dm_db_count->module~dm_kind module~dm_db_count->module~dm_sql module~dm_db_query->module~dm_error module~dm_db_query->module~dm_kind module~dm_db_row->module~dm_db module~dm_db_row->module~dm_error module~dm_db_row->module~dm_util module~dm_error->module~dm_kind module~dm_ascii dm_ascii module~dm_error->module~dm_ascii iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env module~dm_sql->module~dm_ascii module~dm_util->module~dm_error module~dm_util->module~dm_kind

Used by

  • module~~dm_db_json~~UsedByGraph module~dm_db_json dm_db_json module~dmpack dmpack module~dmpack->module~dm_db_json

Interfaces

public interface dm_db_json_select_beats

Generic JSON logs select function.

  • private function db_json_select_beats_array(db, strings, limit, nbeats) result(rc)

    Returns beats in JSON format in allocatable string type array strings.

    If no beats have been found, the array will be empty, and the function returns E_DB_NO_ROWS.

    The function returns the following error codes:

    • E_ALLOC if memory allocation failed.
    • E_DB_BIND if value binding failed.
    • E_DB_NO_ROWS if no rows are returned.
    • E_DB_PREPARE if statement preparation failed.
    • E_DB_TYPE if returned columns are unexpected.

    Arguments

    Type IntentOptional Attributes Name
    type(db_type), intent(inout) :: db

    Database type.

    type(string_type), intent(out), allocatable :: strings(:)

    Returned JSON array.

    integer(kind=i8), intent(in), optional :: limit

    Max. number of beats.

    integer(kind=i8), intent(out), optional :: nbeats

    Number of beats.

    Return Value integer

  • private function db_json_select_beats_iter(db, dbs, json, limit, validate) result(rc)

    Iterator function that returns beats in JSON format in allocatable string json. The statement dbs must be finalised once finished.

    If no beats have been found, the string will be empty, and the function returns E_DB_NO_ROWS.

    The function returns the following error codes:

    • E_DB_BIND if value binding failed.
    • E_DB_DONE if statement finished.
    • E_DB_PREPARE if statement preparation failed.
    • E_DB_TYPE if returned columns are unexpected.

    Arguments

    Type IntentOptional Attributes Name
    type(db_type), intent(inout) :: db

    Database type.

    type(db_stmt_type), intent(inout) :: dbs

    Database statement type.

    character(len=:), intent(out), allocatable :: json

    Returned JSON.

    integer(kind=i8), intent(in), optional :: limit

    Max. number of beats.

    logical, intent(in), optional :: validate

    Validate column types.

    Return Value integer

public interface dm_db_json_select_logs

Generic JSON logs select function.

  • private function db_json_select_logs_array(db, strings, node_id, sensor_id, target_id, source, from, to, min_level, max_level, error, desc, limit, nlogs) result(rc)

    Returns logs in JSON format in allocatable string type array strings.

    If no logs have been found, the array will be empty, and the function returns E_DB_NO_ROWS.

    The function returns the following error codes:

    • E_ALLOC if memory allocation failed.
    • E_DB_BIND if value binding failed.
    • E_DB_FINALIZE if statement finalisation failed.
    • E_DB_NO_ROWS if no rows are returned.
    • E_DB_PREPARE if statement preparation failed.
    • E_DB_TYPE if returned columns are unexpected.

    Arguments

    Type IntentOptional Attributes Name
    type(db_type), intent(inout) :: db

    Database type.

    type(string_type), intent(out), allocatable :: strings(:)

    Returned JSON array.

    character(len=*), intent(in), optional :: node_id

    Node id.

    character(len=*), intent(in), optional :: sensor_id

    Sensor id.

    character(len=*), intent(in), optional :: target_id

    Target id.

    character(len=*), intent(in), optional :: source

    Source name.

    character(len=*), intent(in), optional :: from

    Begin of time range.

    character(len=*), intent(in), optional :: to

    End of time range.

    integer, intent(in), optional :: min_level

    Minimum log level.

    integer, intent(in), optional :: max_level

    Maximum log level.

    integer, intent(in), optional :: error

    Error code.

    logical, intent(in), optional :: desc

    Descending order.

    integer(kind=i8), intent(in), optional :: limit

    Max. numbers of logs.

    integer(kind=i8), intent(out), optional :: nlogs

    Number of logs.

    Return Value integer

  • private function db_json_select_logs_iter(db, dbs, json, node_id, sensor_id, target_id, source, from, to, min_level, max_level, error, desc, limit, validate) result(rc)

    Iterator function that returns logs in JSON format in allocatable character json. The statement dbs must be finalised once finished.

    If no logs have been found, the string will be empty, and the function returns E_DB_NO_ROWS.

    The function returns the following error codes:

    • E_DB_BIND if value binding failed.
    • E_DB_DONE if statement finished.
    • E_DB_PREPARE if statement preparation failed.
    • E_DB_TYPE if returned columns are unexpected.

    Arguments

    Type IntentOptional Attributes Name
    type(db_type), intent(inout) :: db

    Database type.

    type(db_stmt_type), intent(inout) :: dbs

    Database statement type.

    character(len=:), intent(out), allocatable :: json

    Returned JSON.

    character(len=*), intent(in), optional :: node_id

    Node id.

    character(len=*), intent(in), optional :: sensor_id

    Sensor id.

    character(len=*), intent(in), optional :: target_id

    Target id.

    character(len=*), intent(in), optional :: source

    Source name.

    character(len=*), intent(in), optional :: from

    Begin of time range.

    character(len=*), intent(in), optional :: to

    End of time range.

    integer, intent(in), optional :: min_level

    Minimum log level.

    integer, intent(in), optional :: max_level

    Maximum log level.

    integer, intent(in), optional :: error

    Error code.

    logical, intent(in), optional :: desc

    Descending order.

    integer(kind=i8), intent(in), optional :: limit

    Max. numbers of logs.

    logical, intent(in), optional :: validate

    Validate column types.

    Return Value integer

public interface dm_db_json_select_nodes

Generic JSON nodes select function.

  • private function db_json_select_nodes_array(db, strings, limit, nnodes) result(rc)

    Returns nodes in JSON format in allocatable string type array strings.

    If no nodes have been found, the array will be empty, and the function returns E_DB_NO_ROWS.

    The function returns the following error codes:

    • E_ALLOC if memory allocation failed.
    • E_DB_BIND if value binding failed.
    • E_DB_NO_ROWS if no rows are returned.
    • E_DB_PREPARE if statement preparation failed.
    • E_DB_TYPE if returned columns are unexpected.

    Arguments

    Type IntentOptional Attributes Name
    type(db_type), intent(inout) :: db

    Database type.

    type(string_type), intent(out), allocatable :: strings(:)

    Returned JSON array.

    integer(kind=i8), intent(in), optional :: limit

    Max. number of nodes.

    integer(kind=i8), intent(out), optional :: nnodes

    Number of nodes.

    Return Value integer

  • private function db_json_select_nodes_iter(db, dbs, json, limit, validate) result(rc)

    Iterator function that returns nodes in JSON format in allocatable string json. The statement dbs must be finalised once finished.

    If no nodes have been found, the string will be empty, and the function returns E_DB_NO_ROWS.

    The function returns the following error codes:

    • E_DB_BIND if value binding failed.
    • E_DB_DONE if statement finished.
    • E_DB_PREPARE if statement preparation failed.
    • E_DB_TYPE if returned columns are unexpected.

    Arguments

    Type IntentOptional Attributes Name
    type(db_type), intent(inout) :: db

    Database type.

    type(db_stmt_type), intent(inout) :: dbs

    Database statement type.

    character(len=:), intent(out), allocatable :: json

    Returned JSON.

    integer(kind=i8), intent(in), optional :: limit

    Max. number of nodes.

    logical, intent(in), optional :: validate

    Validate column types.

    Return Value integer


Functions

public function dm_db_json_select_beat(db, json, node_id) result(rc)

Returns heartbeat associated with given node id as allocatable character json in JSON format.

Read more…

Arguments

Type IntentOptional Attributes Name
type(db_type), intent(inout) :: db

Database type.

character(len=:), intent(out), allocatable :: json

Returned JSON.

character(len=*), intent(in) :: node_id

Node id.

Return Value integer

public function dm_db_json_select_log(db, json, log_id) result(rc)

Returns log associated with given id as allocatable character in JSON format in json. If no log has been found, the string will be empty and the function returns E_DB_NO_ROWS.

Read more…

Arguments

Type IntentOptional Attributes Name
type(db_type), intent(inout) :: db

Database type.

character(len=:), intent(out), allocatable :: json

Returned JSON.

character(len=*), intent(in) :: log_id

Log id.

Return Value integer

public function dm_db_json_select_node(db, json, node_id) result(rc)

Returns node associated with given node id as allocatable character json in JSON format.

Read more…

Arguments

Type IntentOptional Attributes Name
type(db_type), intent(inout) :: db

Database type.

character(len=:), intent(out), allocatable :: json

Returned JSON.

character(len=*), intent(in) :: node_id

Node id.

Return Value integer