grepros 1.2.2
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
SqlSink Class Reference

Writes SQL schema file for message type tables and topic views. More...

Inheritance diagram for SqlSink:
Inheritance graph

Public Member Functions

 __init__ (self, args=None, **kwargs)
 
 close (self)
 Rewrites out everything to SQL schema file, ensuring all source metas.
 
 emit (self, topic, msg, stamp=None, match=None, index=None)
 Writes out message type CREATE TABLE statements to SQL schema file.
 
 validate (self)
 Returns whether "dialect" and "nesting" and "overwrite" parameters contain supported values and file is writable.
 
- Public Member Functions inherited from Sink
 __init__ (self, args=None, **kwargs)
 
 __enter__ (self)
 Context manager entry.
 
 __exit__ (self, exc_type, exc_value, traceback)
 Context manager exit, closes sink.
 
 autodetect (cls, target)
 Returns true if target is recognizable as output for this sink class.
 
 bind (self, source)
 Attaches source to sink.
 
 close (self)
 Shuts down output, closing any files or connections.
 
 configure (self, args=None, **kwargs)
 Updates sink configuration.
 
 emit (self, topic, msg, stamp=None, match=None, index=None)
 Outputs ROS message.
 
 emit_meta (self)
 Outputs source metainfo like bag header as debug stream, if not already emitted.
 
 flush (self)
 Writes out any pending data to disk.
 
 is_highlighting (self)
 Returns whether this sink requires highlighted matches.
 
 thread_excepthook (self, text, exc)
 Handles exception, used by background threads.
 
 validate (self)
 Returns whether sink prerequisites are met (like ROS environment set if LiveSink).
 
 __init__ (self, args=None, **kwargs)
 
 close (self)
 Clears data structures.
 
 validate (self)
 Returns whether arguments are valid.
 

Public Attributes

 close
 
 valid
 
- Public Attributes inherited from Sink
 args
 
 source
 inputs.Source instance bound to this sink
 
 valid
 Result of validate()
 
- Public Attributes inherited from SqlMixin
 DIALECTS
 

Static Public Attributes

 DEFAULT_ARGS = dict(WRITE_OPTIONS={}, VERBOSE=False)
 Constructor argument defaults.
 
tuple FILE_EXTENSIONS = (".sql", )
 Auto-detection file extensions.
 
list MESSAGE_TYPE_BASECOLS
 Default columns for message type tables, as [(column name, ROS type)].
 
- 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.
 

Detailed Description

Writes SQL schema file for message type tables and topic views.

Output will have:

  • table "pkg/MsgType" for each topic message type, with ordinary columns for scalar fields, and structured columns for list fields; 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 "/full/topic/name" for each topic, selecting from the message type table

Definition at line 43 of file sql.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
Parameters
argsarguments as namespace or dictionary, case-insensitive; or a single path as the file to write
args.writeoutput file path
args.write_options
{"dialect": SQL dialect if not default,
 "nesting": true|false to created nested type tables,
 "overwrite": whether to overwrite existing file
              (default false)}
args.metawhether to emit metainfo
args.verbosewhether to emit debug information
kwargsany and all arguments as keyword overrides, case-insensitive

Reimplemented from Sink.

Definition at line 71 of file sql.py.

Member Function Documentation

◆ close()

close (   self)

Rewrites out everything to SQL schema file, ensuring all source metas.

Reimplemented from Sink.

Definition at line 131 of file sql.py.

◆ emit()

emit (   self,
  topic,
  msg,
  stamp = None,
  match = None,
  index = None 
)

Writes out message type CREATE TABLE statements to SQL schema file.

Reimplemented from Sink.

Definition at line 119 of file sql.py.

◆ validate()

validate (   self)

Returns whether "dialect" and "nesting" and "overwrite" parameters contain supported values and file is writable.

Reimplemented from Sink.

Definition at line 97 of file sql.py.

Member Data Documentation

◆ close

close

Definition at line 90 of file sql.py.

◆ DEFAULT_ARGS

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

Constructor argument defaults.

Definition at line 53 of file sql.py.

◆ FILE_EXTENSIONS

tuple FILE_EXTENSIONS = (".sql", )
static

Auto-detection file extensions.

Definition at line 46 of file sql.py.

◆ MESSAGE_TYPE_BASECOLS

list MESSAGE_TYPE_BASECOLS
static
Initial value:
= [("_topic", "string"),
("_timestamp", "time"), ]

Default columns for message type tables, as [(column name, ROS type)].

Definition at line 49 of file sql.py.

◆ valid

valid

Definition at line 112 of file sql.py.


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