dbbroker
Data storage is abstracted in the commhub ecosystem. DbBroker handles all data storage requests. It interfaces to an appropriate database engine to provide data storage per the Datastore class.
At present, DbBroker supports MySQL and CSV databases. Future plans include support for SQL Server, Oracle, Postgres, Mongo, Cassandra, and others.
Use the tdbcmd or tdatadump utility to query/change the database from the command line.
DbBroker reads these attributes that originate from the commhub.ini file:
Keyword |
Value |
dbtypes |
Comma separated list of types of DB connections supported. Valid types: csv, ini, mysql, postgresql |
dbtype.tables |
Comma separated list of table names. Use '*' to allow all tables of the dbtype. |
dbtype.tablename.filename |
Specifies the file that contains the database table of the type and name specified. This applies to file-based database types only, such as csv. |
dbtype.server |
The database server hostname to contact for the DB type, such as mysql or postgresql. |
dbtype.user |
The user id to use to log into the DB. |
dbtype.passwd |
The password to use to log into the DB. |
dbtype.dbname |
The DB name to use to log into the DB. |
dbtype.dbport |
The TCP port to use to log into the DB, if different than default. |
To use the database, use the Datastore class.
View detailed database tables schemas for these tables:
DbBroker receives XML data that contains the command and parameters. The XML data varies by command, but the tag cmd contains the command, table contains the table to operate on, and recno contains the relevant record number..
Command |
Description |
get |
Fetch a specific record field |
set |
Set a specific record field |
getrec |
Fetch a specific record with all or some of its fields |
setrec |
Set a specific record with all or some of its fields |
create |
Create a new table. |
open |
Open a database table. |
assert |
Assert a new database table schema. |
query |
Query a database table. |
append |
Append a record. |
delete |
Delete a record. |
finfo |
Query field information. |
tinfo |
Query table information. |
rinfo |
Query record information |
ftypes |
Query field types. |
fids |
Query field ids. |
lock |
Lock a record. |
unlock |
Unlock a record. |
fid |
Query field id for a field name. |
newfid |
Add a field to database table. |
newenum |
Create a new enumeration for a field. |
pack |
Pack the database table (if supported). |
close |
Stop using the database table. |
hello |
Simple echo test to dbbroker. |
quit |
Instruct dbbroker to exit. |
The XML tags are:
Tag |
Description |
cmd |
The data storage operation requested. |
table |
The name of the table to manipulate. |
recno |
The record number to manipulate. |
field |
The field name. |
value |
The value of the field. |
fields |
A comma separated list of fields. |
schemafile |
A filename that contains a database table schema. |
query |
A query string. |
data |
Data to support the operation. (Operation specific.) |
type |
Field type. |
size |
Field size in bytes. |
enumid |
Enumeration id in an enumerated field. |
enumname |
Enumeration value in an enumerated field. |
Command |
Description |
DBResponse |
Data storage operation was successful. Payload contains response. |
DBError |
Data storage operation failed. Payload contains error information. |