The dbx Command

The dbx command is used to manage database driver extensions. The command has the following subcommands:

dbx defined

dbx defined dbtype
Dbx.Defined(dbtype)

Check whether a driver module for the specified database type is either already loaded, or available. If a module can be found, and it not yet loaded, it is automatically loaded.

The return value is a boolean status code. No error is generated when the database type cannot be resolved to a module.

Example:

dbx defined mysql

dbx exists

dbx exists dbtype
d.exists()
Dbx.Exists(dbtype)

Check whether a driver module for the specified database type is already loaded. No attempt is made to auto-load a module if it is not already loaded.

The return value is a boolean status code. No error is generated when the database type cannot be resolved to a module.

Example:

dbx exists postgresql

dbx get

dbx get dbtype attribute
d.get(attribute)
d.attribute
d[attribute]
Dbx.Get(dbtype,attribute)

Get an attribute the database driver module. The following attributes can be queried:

Example:

dbx get mysql version

dbx list

dbx list ?pattern?
Dbx.List(?pattern=?)

Return a list of all currently loaded database driver modules. The output may be filtered by a string pattern. Its syntax is the same as in standard Tcl command string match .

dbx load

dbx load dbtype ?objectfile?...
dbx load all
Dbx.Load(dbtype,?objectfile?,...)
Dbx.Load(“all”)

Load or re-load a database interface module. If no object file name is specified, the name of the shared library, DLL or bundle is automatically constructed from the database type name, and the module is located by traversing the database module path, which is accessible via the control array element ::cactvs(databasepath) , but this mechanism can be overridden by specifying an explicit object file with or without a path.

The all command variant locates all currently available database interface modules in the module search path and loads these. This is primarily useful for automatic database interface attribute documentation.

Example:

dbx load mysql

Above statement locates and loads the standard driver for interacting with Mysql and Mariadb databases. Depending on the platform, the object file would be named dbx_mysql.so , dbx_mysql.dll, etc.. It is located in the module directory of a standard Cactvs distribution.

In case the interface module is already loaded, the current module is unloaded first, so this command can be used to update a driver in a running application. Nevertheless, swapping a driver while database access objects which rely on this driver are in existence in the current process is usually not a good idea, though the details on whether this is possible or not depend on the module implementation.

For Tcl , the return value of the command is the slot in the handler module table the module has been loaded into. This corresponds to the value of the slot attribute which can be queried via dbx get . For Python , the return value is a module reference.

dbx ref

Dbx.Ref(dbtype)

Python -only method to get a reference of the module, which allows terser attribute retrieval commands and other operations.

dbx subcommands

dbx subcommands
dir(Dbx)

This command returns a list of all the defined subcommands of the dbx command.