
Public Member Functions | |
| def | __init__ (self, args=None, **kwargs) |
| def | close (self) |
| def | validate (self) |
Static Public Attributes | |
| 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 | _convert_column_value (self, value, typename) |
| def | _convert_time_value (self, value, typename) |
| def | _get_dialect_option (self, option) |
| def | _make_column_names (self, col_names) |
| def | _make_column_type (self, typename, fallback=None) |
| def | _make_column_value (self, value, typename=None) |
| def | _make_entity_name (self, category, args) |
| def | _make_message_insert_sql (self, topic, msg, extra_cols=()) |
| def | _make_name (self, category, name, existing=()) |
| def | _make_topic_data (self, topic, msg, exclude_cols=()) |
| def | _make_topic_insert_sql (self, topic, msg) |
| def | _make_type_data (self, msg, extra_cols=(), rootmsg=None) |
| def | _make_type_insert_sql (self, msg) |
| def | _make_update_sql (self, table, values, where=()) |
| def | _validate_dialect (self) |
| def | _validate_dialect_file (self) |
Private Attributes | |
| _args | |
| _dialect | |
| _nesting | |
| _schema | |
| _sql_cache | |
| _topics | |
| _types | |
Base class for producing SQL for topics and messages. Can load additional SQL dialects or additional options for existing dialects from a YAML/JSON file.
Definition at line 25 of file sqlbase.py.
| def grepros.plugins.auto.sqlbase.SqlMixin.__init__ | ( | self, | |
args = None, |
|||
| ** | kwargs | ||
| ) |
@param args arguments as namespace or dictionary, case-insensitive
@param args.write_options ```
{"dialect": SQL dialect if not default,
"nesting": true|false to created nested type tables}
```
@param kwargs any and all arguments as keyword overrides, case-insensitive
Reimplemented in grepros.plugins.auto.postgres.PostgresSink, grepros.plugins.auto.dbbase.BaseDataSink, grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.sql.SqlSink.
Definition at line 40 of file sqlbase.py.
|
private |
Returns ROS value converted to dialect value.
Definition at line 345 of file sqlbase.py.
|
private |
Returns ROS time/duration value converted to dialect value.
Definition at line 358 of file sqlbase.py.
|
private |
Returns option for current SQL dialect, falling back to default dialect.
Definition at line 371 of file sqlbase.py.
|
private |
Returns valid unique names for table columns.
Definition at line 286 of file sqlbase.py.
|
private |
Returns column type for SQL. @param fallback fallback typename to use for lookup if no mapping for typename
Definition at line 317 of file sqlbase.py.
|
private |
Returns column value suitable for inserting to database.
Reimplemented in grepros.plugins.auto.postgres.PostgresSink.
Definition at line 294 of file sqlbase.py.
|
private |
Returns valid unique name for table/view. @param args format arguments for table/view name template
Definition at line 250 of file sqlbase.py.
|
private |
Returns ("INSERT ..", [args]) for inserting into message type table.
@param extra_cols list of additional table columns, as [(name, value)]
Definition at line 211 of file sqlbase.py.
|
private |
Returns a valid unique name for table/view/column. Replaces invalid characters and constrains length. If name already exists, appends counter like " (2)".
Definition at line 263 of file sqlbase.py.
|
private |
Returns full data dictionary for topic, including view name and SQL.
@param exclude_cols list of column names to exclude from view SELECT, if any
@return {"name": topic name, "type": message type name as "pkg/Cls",
"table_name": message type table name, "view_name": topic view name,
"md5": message type definition MD5 hash, "sql": "CREATE VIEW .."}
Definition at line 122 of file sqlbase.py.
|
private |
Returns ("INSERT ..", [args]) for inserting into topics-table.
Definition at line 189 of file sqlbase.py.
|
private |
Returns full data dictionary for message type, including table name and SQL.
@param rootmsg top message this message is nested under, if any
@param extra_cols additional table columns, as [(column name, column def)]
@return {"type": message type name as "pkg/Cls",
"table_name": message type table name,
"definition": message type definition,
"cols": [(column name, column type)],
"md5": message type definition MD5 hash, "sql": "CREATE TABLE .."}
Definition at line 152 of file sqlbase.py.
|
private |
Returns ("INSERT ..", [args]) for inserting into types-table.
Definition at line 200 of file sqlbase.py.
|
private |
Returns ("UPDATE ..", [args]).
Definition at line 238 of file sqlbase.py.
|
private |
Returns whether "dialect" is valid in args.WRITE_OPTIONS.
Definition at line 101 of file sqlbase.py.
|
private |
Returns whether "dialect-file" is valid in args.WRITE_OPTIONS.
Definition at line 67 of file sqlbase.py.
| def grepros.plugins.auto.sqlbase.SqlMixin.close | ( | self | ) |
Clears data structures.
Reimplemented in grepros.plugins.auto.dbbase.BaseDataSink, and grepros.plugins.sql.SqlSink.
Definition at line 114 of file sqlbase.py.
| def grepros.plugins.auto.sqlbase.SqlMixin.validate | ( | self | ) |
Returns whether arguments are valid. Verifies that "dialect-file" is valid and "dialect" contains supported value, if any.
Reimplemented in grepros.plugins.auto.dbbase.BaseDataSink, grepros.plugins.auto.postgres.PostgresSink, grepros.plugins.auto.sqlite.SqliteSink, and grepros.plugins.sql.SqlSink.
Definition at line 58 of file sqlbase.py.
|
private |
Definition at line 49 of file sqlbase.py.
|
private |
Definition at line 54 of file sqlbase.py.
|
private |
Definition at line 55 of file sqlbase.py.
|
private |
Definition at line 52 of file sqlbase.py.
|
private |
Definition at line 53 of file sqlbase.py.
|
private |
Definition at line 50 of file sqlbase.py.
|
private |
Definition at line 51 of file sqlbase.py.
|
static |
Constructor argument defaults.
Definition at line 37 of file sqlbase.py.
|
static |
Default SQL dialect used if dialect not specified.
Definition at line 34 of file sqlbase.py.
|
static |
Supported SQL dialects and options.
Definition at line 377 of file sqlbase.py.
|
static |
Words that need quoting if in name context, like table name.
Combined from reserved words for Postgres, SQLite, MSSQL, Oracle et al.
Definition at line 513 of file sqlbase.py.