Database
This is a sub-element which must contain the following attributes:
Attribute | Default | Notes |
---|---|---|
type |
dbi |
One of dbi , sdp or mongo . |
name |
default |
You may have one default database of each type of database. The correct one will be selected to match the type parameter on the dataset_dir definition.For a simple database connection, the default name of default is fine. If your application wishes to use more than one database instance of a type, use this field to distinguish them.Within each dataset you may specify the database name to be used for executing that dataset. |
connection |
dbi:Pg:<app-name> |
For dbi databases, this is a DBI connection string. e.g.dbi:Sybase:server=localhost;database=Demo For sdp databases, this is a SOAP proxy address, e.g.:http://localhost/ssas_datapump/msmdpump.dll For mongo databases, this is a Mongo connection string, e.g.:mongodb://localhost |
username |
<empty-string> |
This is the username Jarvis uses to connect to the database for all requests. • For dbi this is passed in the DBI connection.• For sdp this is passed as HTTP Basic Authorization.• For mongo this is not currently used. |
password |
<empty-string> |
This is the password Jarvis uses to connect to the database for all requests. See usage notes for username above. |
prepare |
<empty-string> |
Optional parameters passed on to DBI::prepare for dbi databases.E.g. <database connect="..." prepare="pg_server_prepare => 0"/> |
post_connect |
<empty-string> |
For dbi databases, an SQL command that is executed immediately after a connection has been established. E.g. <database connect="..." post_connect="SET ANSI_WARNINGS, ANSI_PADDING, ANSI_NULLS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON;"/> Not used currently for sdp or mongo databases.If you need to execute more than one command, use the alternative post_connect_commands syntax described below. This attribute is ignored if post_connect_commands are specified. |
The database configuration supports contained dbh_attributes
tags which are passed to the the database connection method when connecting to the database.
For example:
<database connect="dbi:Sybase:server=localhost;database=mydb" username="sa" password="sa" post_connect="SET ANSI_WARNINGS, ANSI_PADDING, ANSI_NULLS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON;">
<dbh_attributes>
<attribute name="syb_chained_txn" value="0"/>
</dbh_attributes>
</database>
Each dbh_attributes
sub-element named attribute
has name
and value
attributes.
These attributes are used as follows:
- For
dbi
databases, as the fourth argument toDBI->connect ()
. - For
sdp
databases, thecatalog
attribute is the SDP catalog name. - For
mongo
databases, as the second argument toMongoDB->connect ()
.
The pre_connect
hook may extend/modify this attribute structure.
Note: Nested arguments can be specified using a .
separator in the name. E.g. for MongoDB, SSL connection arguments can be specified.
<parameter name="ssl.ca_cert" value="testcert.ca"/>
<parameter name="ssl.pem_file" value="testpem.pem"/>
Note: When connecting to MS SQL Server on a Linux platform via the DBD::Sybase driver
, using DBD::Sybase
versions later than v1.00, the use of the DBH attribute syb_chained_txn
is required, lest the following error occur:
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. Server message number=3902 severity=16 state=1 line=2
The database configuration also supports contained post_connect_commands
tags.
For example:
<database connect="dbi:SQLite:dbname=main.db" username="" password="">
<post_connect_commands>
<command>PRAGMA foreign_keys = ON</command>
<command>PRAGMA journal_Mode = TRUNCATE</command>
<command>ATTACH DATABASE ‘secondary.db’ AS secondary</command>
</post_connect_commands>
</database>
Each post_connect_commands
sub-element named command
contains a single command to be executed. Like the database post_connect
attribute, these commands are executed immediately after a dbi
database connection has been established. Commands are executed in configuration order.
The database post_connect
attribute is ignored if the post_connect_commands
tag is specified.