PI: import-db
The purpose of an import-db PI is to produce an XML-fragment from a databasequery result and replace the PI with this fragment.
<?_wxt import-db
host=""
database=""
databasetype=""
driver=""
user=""
password=""
sql=""
transformation=""
xpath=""
uri="" ?>
Alternative form
<?_wxt import-db
connectionstring=""
sql=""
transformation=""
xpath=""
uri="" ?>
The parameters are:
| uri(optional and recommanded) | A file-URI which may be absolute or relative to the owning groups location. The result of a database transaction will be written to this location. The result may be a support when writing transformations and will serve as a backup if the database is temporary unavailable. |
| transformation(optional) |
A transformation identifier (see: transformation-element) or a grouprelative or absolute location for a transformationfile.
You may use parameters in the transformation.
This transformation is applied to the content
before it is imported.
You may use the word: _table for the transformation.
This will produce a set of HTML tables describing the result of the
database transactions in a simple way.
Omitting the transformation will simply return all result-rows
from the database transaction(s).
|
| xpathoptional | Identifies what we want to extract from the (transformed) databasequery result. |
| database(mandatory or in connectionstring) | A string which identifies the database. |
| databasetype(mandatory or in connectionstring) | A string which identifies the databasetype. |
| host(mandatory or in connectionstring) | A string which identifies the host. |
| user(mandatory or in connectionstring) | The user of the database. |
| password(mandatory or in connectionstring) | The users password. |
| driver(optional) | The databsedriver to be used. WXT reckognize the shortforms psql(postgres) and mysgl, and attempts to find a driver for those databases. You may spesify any driver as long as you are sure that the driver is available in the classpath. |
| sql(optional) | SQL-statements of type SELECT, separated by semicolon. Overrides sqlfile |
| sqlfile(optional) | A file which contains SQL-statements of type SELECT, separated by semicolon. |
Some examples:
<dbcontent
uri="frascript/contentproduced.xml"
database="db1"
host="localhost"
driver="org.gjt.mm.mysql.Driver"
user="bs"
password="thepassword"
sql="SELECT * FROM perstab"
transformation="_table"/>
<dbcontent
connectionstring="jdbc:mysql://localhost/db1?user=bs&password=thepassword"
uri="frascript/contentproduced.xml"
sql="SELECT * FROM perstab"
transformation="T"
xpath="first_name"/>