Public Member Functions | |
def | __init__ (self, args=None, **kwargs) |
def | close (self) |
def | close_output (self) |
def | emit (self, topic, msg, stamp=None, match=None, index=None) |
def | validate (self) |
![]() | |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_value, traceback) |
def | autodetect (cls, target) |
def | bind (self, source) |
def | emit_meta (self) |
def | flush (self) |
def | is_highlighting (self) |
def | thread_excepthook (self, text, exc) |
Public Attributes | |
COMMIT_INTERVAL | |
db | |
Database connection. More... | |
![]() | |
args | |
source | |
inputs.Source instance bound to this sink More... | |
valid | |
Result of validate() More... | |
Static Public Attributes | |
int | COMMIT_INTERVAL = 1000 |
Number of emits between commits; 0 is autocommit. More... | |
DEFAULT_ARGS = dict(META=False, WRITE_OPTIONS={}, VERBOSE=False) | |
Constructor argument defaults. More... | |
ENGINE = None | |
Database engine name, overridden in subclasses. More... | |
list | MESSAGE_TYPE_BASECOLS |
Default columns for pkg/MsgType tables. More... | |
list | MESSAGE_TYPE_NESTCOLS |
Additional default columns for pkg/MsgType tables with nesting output. More... | |
list | MESSAGE_TYPE_TOPICCOLS |
Default topic-related columns for pkg/MsgType tables. More... | |
![]() | |
DEFAULT_ARGS = dict(META=False) | |
Constructor argument defaults. More... | |
tuple | FILE_EXTENSIONS = () |
Auto-detection file extensions for subclasses, as (".ext", ) More... | |
![]() | |
DEFAULT_ARGS = dict(META=False, WRITE_OPTIONS={}, MATCH_WRAPPER=None, VERBOSE=False) | |
Constructor argument defaults. More... | |
string | DEFAULT_DIALECT = "sqlite" |
Default SQL dialect used if dialect not specified. More... | |
dictionary | DIALECTS |
Supported SQL dialects and options. More... | |
list | KEYWORDS |
Words that need quoting if in name context, like table name. More... | |
Private Member Functions | |
def | _connect (self) |
def | _ensure_columns (self, cols) |
def | _ensure_execute (self, sql, args) |
def | _execute_insert (self, sql, args) |
def | _executemany (self, sql, argses) |
def | _executescript (self, sql) |
def | _get_next_id (self, table) |
def | _init_db (self) |
def | _load_schema (self) |
def | _make_cursor (self) |
def | _make_db_label (self) |
def | _populate_type (self, topic, msg, stamp, rootmsg=None, parent_type=None, parent_id=None) |
def | _process_message (self, topic, msg, stamp) |
def | _process_topic (self, topic, msg) |
def | _process_type (self, msg, rootmsg=None) |
Private Attributes | |
_checkeds | |
_close_printed | |
_cursor | |
_dialect | |
_nested_counts | |
_nesting | |
_sql_queue | |
Base class for writing messages to a database. Output will have: - table "topics", with topic and message type names - table "types", with message type definitions plus: - table "pkg/MsgType" for each topic message type, with detailed fields, BYTEA fields for uint8[], array fields for scalar list attributes, and JSONB fields for lists of ROS messages; with foreign keys if nesting else subtype values as JSON dictionaries; plus underscore-prefixed fields for metadata, like `_topic` as the topic name. If not nesting, only topic message type tables are created. - view "/full/topic/name" for each topic, selecting from the message type table If a message type table already exists but for a type with a different MD5 hash, the new table will have its MD5 hash appended to end, as "pkg/MsgType (hash)".
def grepros.plugins.auto.dbbase.BaseDataSink.__init__ | ( | self, | |
args = None , |
|||
** | kwargs | ||
) |
@param args arguments as namespace or dictionary, case-insensitive; or a single item as the database connection string @param args.write database connection string @param args.write_options ``` {"commit-interval": transaction size (0 is autocommit), "nesting": "array" to recursively insert arrays of nested types, or "all" for any nesting)} ``` @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 grepros.outputs.Sink.
Reimplemented in grepros.plugins.auto.postgres.PostgresSink, and grepros.plugins.auto.sqlite.SqliteSink.
|
private |
Returns new database connection.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
|
private |
|
private |
Executes INSERT statement, returns inserted ID.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
Executes SQL with all args sequences.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
Executes SQL with one or more statements.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
Returns next ID value for table.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
Opens database connection, and populates schema if not already existing.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
Populates instance attributes with schema metainfo.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
|
private |
Returns formatted label for database.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.auto.postgres.PostgresSink.
|
private |
|
private |
Inserts pkg/MsgType row for this message. Inserts sub-rows for subtypes in message if nesting enabled. Commits transaction if interval due.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink.
|
private |
|
private |
def grepros.plugins.auto.dbbase.BaseDataSink.close | ( | self | ) |
Closes database connection, if any, emits metainfo.
Reimplemented from grepros.outputs.Sink.
def grepros.plugins.auto.dbbase.BaseDataSink.close_output | ( | self | ) |
def grepros.plugins.auto.dbbase.BaseDataSink.emit | ( | self, | |
topic, | |||
msg, | |||
stamp = None , |
|||
match = None , |
|||
index = None |
|||
) |
Writes message to database.
Reimplemented from grepros.outputs.Sink.
Reimplemented in grepros.plugins.auto.sqlite.SqliteSink.
def grepros.plugins.auto.dbbase.BaseDataSink.validate | ( | self | ) |
Returns whether args.write_options has valid values, if any. Checks parameters "commit-interval" and "nesting".
Reimplemented from grepros.outputs.Sink.
Reimplemented in grepros.plugins.auto.postgres.PostgresSink, and grepros.plugins.auto.sqlite.SqliteSink.
|
private |
|
private |
|
private |
|
static |
grepros.plugins.auto.dbbase.BaseDataSink.db |
|
static |
|
static |
|
static |
|
static |
|
static |