DBR Schema and Data Browser
% dbr-browse conf=dbr.conf % dbr-browse conf=foo.conf class=master % dbr-browse conf=foo.conf pkeymax=50 dumpmax=25 highvar=300 highsamp=10
If you have not installed DBR yet:
% perl -I ../lib dbr-browse conf=bar.conf
dbr-browse is a DBR tool that shows you database tables with DBR metadata mixed in. DBR metadata includes the translator type (e.g. UnixTime, Dollars, Enum, Percent), enumeration handles associated with an Enum field, and the forward and backward names of relationships to other tables via foreign keys.
At present, the dbr-admin tool is the preferred method for adding in DBR metadata. Developers will subsequently find dbr-browse a useful tool for coding the correct names in "table paths" when accessing data from a Record object, specifying key values to use with ResultSet's hasmap_single() and hashmap_multi() methods, and when expressing constraints for an Object where() method.
SCHEMA> webshop
TABLE> item 0) items 1) item_shipment 2) received_items
TABLE> 0 TABLE> products
TABLE> 0 type TABLE> 0 type/product_id=432,654,765
TABLE> 0 /item_id=1234 TABLE> 0 /product.brand.name=Ford,GM/type=coupe,wagon,suv TABLE> 0 /order.customer.lastname=Jones
The config file parameter establishes your access to a collection of databases. Those databases that have been scanned will have schema data available. The schemas will be listed and you will be prompted to enter the name of one. Table view mode is now entered. Your remaining inputs will be the name (or number) of a table to view. A blank input will return to the schema prompt; blank input again will exit. A '?' will list all tables, otherwise a list will be shown matching the input. When presented with a list, enter the number for the item or key in the full name. The number must be used if the table name is also a substring of other table names.
The DBR config file. Required.
By default, the "query" class database is queried. You may have other classes defined. The other typical class is "master", which is the read-write instance. default: query
When sample data for a field is requested, this arg sets the maximum number of sample pkey values for the table that will be shown. default: 10
When a field is not specified with a search expression, full records are dumped. This arg controls the maximum number of sample dumps shown. default: 10
This is the threshold number of distinct values for a field that will truncate the values listing. Stands for "high variability" of field values. default: 200
If the values listing is truncated, this sets the number of sample values to display. default: 20
Getting a sample of table field values is very helpful when getting to know a database. A table or result index may be followed with a field specification. If there are less than 200 (or highvar) distinct values in the field, each value and the number of times it occurs will be listed. If there are over 200 (or highvar) distinct values, a sampler of 20 (or highsamp) values will be shown. In any case, a sampler of up to 10 (or pkeymax) of the table's pkeys will be listed with each of the values shown. Multiple fields may be specified, separated by spaces, or "*" for all the table's fields (handy for getting an idea of all the data in the table).
If no field is specified with a search, a maximum of 10 (or dumpmax) records will be shown.
examples/music/browse_test.sh
The get_chunker() and related manual chunking is not required - DBR will do this for us, but for large tables DBR simply has too much overhead when the scan covers the entire table (such as getting stats on the number of records associated with each one of 3 possible "status" field values).
4 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
To install DBR, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBR
CPAN shell
perl -MCPAN -e shell install DBR
For more information on module installation, please visit the detailed CPAN module installation guide.