grepros 1.3.0
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
SqliteSink Class Reference
Inheritance diagram for SqliteSink:
Inheritance graph

Public Member Functions

 __init__ (self, args=None, **kwargs)
 
 emit (self, topic, msg, stamp=None, match=None, index=None)
 
 size (self)
 
 validate (self)
 
- Public Member Functions inherited from BaseDataSink
 close (self)
 
 close_output (self)
 
- Public Member Functions inherited from Sink
 __enter__ (self)
 
 __exit__ (self, exc_type, exc_value, traceback)
 
 autodetect (cls, target)
 
 bind (self, source)
 
 configure (self, args=None, **kwargs)
 
 emit_meta (self)
 
 flush (self)
 
 is_highlighting (self)
 
 thread_excepthook (self, text, exc)
 
- Public Member Functions inherited from RolloverSinkMixin
 close_output (self)
 
 ensure_rollover (self, topic, msg, stamp)
 
 format_output_meta (self)
 
 get_write_options (cls, label)
 
 make_filename (self)
 

Public Attributes

 ENGINE
 
 filename
 
 valid
 
- Public Attributes inherited from BaseDataSink
 close
 
 COMMIT_INTERVAL
 
 db
 Database connection.
 
- Public Attributes inherited from Sink
 args
 
 source
 inputs.Source instance bound to this sink
 
 valid
 Result of validate()
 
- Public Attributes inherited from SqlMixin
 DIALECTS
 
- Public Attributes inherited from RolloverSinkMixin
 filename
 Current output file path.
 

Static Public Attributes

 DEFAULT_ARGS = dict(META=False, WRITE_OPTIONS={}, VERBOSE=False)
 Constructor argument defaults.
 
str ENGINE = "SQLite"
 Database engine name.
 
tuple FILE_EXTENSIONS = (".sqlite", ".sqlite3")
 Auto-detection file extensions.
 
int MAX_INT = 2**63 - 1
 Maximum integer size supported in SQLite, higher values inserted as string.
 
- Static Public Attributes inherited from BaseDataSink
int COMMIT_INTERVAL = 1000
 Number of emits between commits; 0 is autocommit.
 
 DEFAULT_ARGS = dict(META=False, WRITE_OPTIONS={}, VERBOSE=False)
 Constructor argument defaults.
 
 ENGINE = None
 Database engine name, overridden in subclasses.
 
list MESSAGE_TYPE_BASECOLS
 Default columns for pkg/MsgType tables.
 
list MESSAGE_TYPE_NESTCOLS
 Additional default columns for pkg/MsgType tables with nesting output.
 
list MESSAGE_TYPE_TOPICCOLS
 Default topic-related columns for pkg/MsgType tables.
 
- Static Public Attributes inherited from Sink
 DEFAULT_ARGS = dict(META=False)
 Constructor argument defaults.
 
tuple FILE_EXTENSIONS = ()
 Auto-detection file extensions for subclasses, as (".ext", )
 
- Static Public Attributes inherited from SqlMixin
 DEFAULT_ARGS = dict(WRITE_OPTIONS={})
 Constructor argument defaults.
 
str DEFAULT_DIALECT = "sqlite"
 Default SQL dialect used if dialect not specified.
 
dict DIALECTS
 Supported SQL dialects and options.
 
list KEYWORDS
 Words that need quoting if in name context, like table name.
 
- Static Public Attributes inherited from RolloverSinkMixin
 DEFAULT_ARGS = dict(WRITE=None, WRITE_OPTIONS={}, VERBOSE=False)
 Constructor argument defaults.
 
str FILE_META_TEMPLATE = "{name} ({size})"
 
str MULTI_META_TEMPLATE = "\n- {name} ({size}, {mcount}, {tcount})"
 
list OPTIONS_TEMPLATES
 Command-line help templates for rollover options, as [(name, text with s label placeholder)].
 
str START_META_TEMPLATE = "{mcount} in {tcount} to "
 

Detailed Description

Writes messages to an SQLite database.

Output will have:
- table "messages", with all messages as serialized binary data
- table "types", with message definitions
- table "topics", with topic information

plus:
- table "pkg/MsgType" for each message type, with detailed fields,
  and JSON fields for arrays of nested subtypes,
  with foreign keys if nesting else subtype values as JSON dictionaries;
  plus underscore-prefixed fields for metadata, like `_topic` as the topic name.

  If launched with nesting-option, tables will also be created for each
  nested message type.

- view "/topic/full/name" for each topic,
  selecting from the message type table

Definition at line 29 of file sqlite.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
@param   args                 arguments as namespace or dictionary, case-insensitive;
                              or a single path as the name of SQLitefile to write
@param   args.write           name of SQLite file to write, will be appended to if exists
@param   args.write_options   ```
                              {"commit-interval": transaction size (0 is autocommit),
                               "message-yaml": populate messages.yaml (default true),
                               "nesting": "array" to recursively insert arrays
                                          of nested types, or "all" for any nesting),
                               "overwrite": whether to overwrite existing file
                                            (default false),
                               "rollover-size": bytes limit for individual output files,
                               "rollover-count": message limit for individual output files,
                               "rollover-duration": time span limit for individual output files,
                                                    as ROS duration or convertible seconds,
                               "rollover-template": output filename template, supporting
                                                    strftime format codes like "%H-%M-%S"
                                                    and "%(index)s" as output file index}
                              ```
@param   args.meta            whether to emit metainfo
@param   args.verbose         whether to emit debug information
@param   kwargs               any and all arguments as keyword overrides, case-insensitive

Reimplemented from BaseDataSink.

Definition at line 65 of file sqlite.py.

Member Function Documentation

◆ emit()

emit (   self,
  topic,
  msg,
  stamp = None,
  match = None,
  index = None 
)
Writes message to database.

Reimplemented from BaseDataSink.

Definition at line 123 of file sqlite.py.

◆ size()

size (   self)
Returns current file size in bytes, including journals, or None if size lookup failed.

Reimplemented from RolloverSinkMixin.

Definition at line 132 of file sqlite.py.

◆ validate()

validate (   self)
Returns whether "commit-interval" and "nesting" in args.write_options have valid value, if any,
and file is writable; parses "message-yaml" and "overwrite" from args.write_options.

Reimplemented from BaseDataSink.

Definition at line 97 of file sqlite.py.

Member Data Documentation

◆ DEFAULT_ARGS

DEFAULT_ARGS = dict(META=False, WRITE_OPTIONS={}, VERBOSE=False)
static

Constructor argument defaults.

Definition at line 62 of file sqlite.py.

◆ ENGINE [1/2]

str ENGINE = "SQLite"
static

Database engine name.

Definition at line 53 of file sqlite.py.

◆ ENGINE [2/2]

ENGINE

Definition at line 107 of file sqlite.py.

◆ FILE_EXTENSIONS

tuple FILE_EXTENSIONS = (".sqlite", ".sqlite3")
static

Auto-detection file extensions.

Definition at line 56 of file sqlite.py.

◆ filename

filename

Definition at line 135 of file sqlite.py.

◆ MAX_INT

int MAX_INT = 2**63 - 1
static

Maximum integer size supported in SQLite, higher values inserted as string.

Definition at line 59 of file sqlite.py.

◆ valid

valid

Definition at line 116 of file sqlite.py.


The documentation for this class was generated from the following file: