The configuration of the
DBI database is done by setting attributes in
additional Database directives after the initial defining line as described above. For example, the following
defines the database arbitrary
as a
DBI database, sets the data source
(DSN) to an appropriate value for an mSQL database named
minivend
on port 1114 of the local machine:
Database arbitrary arbitrary.asc SQL Database arbitrary DSN dbi:mSQL:minivend:localhost:1114
As a shorthand method, you can instead include the DSN as the type:
Database arbitrary arbitrary.asc dbi:mSQL:minivend:localhost:1114
Supported configuration attributes include (but are not limited to):
dbi:mSQL:minivend:othermachine.my.com:1112
where mSQL selects the driver (case
IS important), minivend
selects the database, othermachine.my.com
selects the host, and 1112 is the port. On many systems, dbi:mSQL:minivend
will work just fine. (The minivend
database must already exist, of course.)
This is the same as the DBI_DSN environment variable -- if you don't set the DSN parameter, then the value of DBI_DSN will be used to try and find the proper database to connect to.
char(128).
In fact that is the default if you do not choose a type for a column. You can have as many lines as needed. This is not a
DBI parameter, it is specific to MiniVend.
[item-data ...]
, [loop-data ...]
, [item-field ...
, etc. Typically used for Oracle and some other
SQL implementations.
The supported list as of this release of MiniVend is:
ChopBlanks CompatMode LongReadLen LongTruncOk PrintError RaiseError Warn
Issue the shell command perldoc DBI
for more information.
Here is an example of a completely set up
DBI database on mySQL, using a comma-separated value input, setting the
DBI attribute LongReadLen to retrieve an entire field, and changing some field definitions from the default char(128):
Database products products.csv dbi:mysql:minivend Database products USER minivend Database products PASS nevairbe Database products DELIMITER CSV # Set a DBI attribute Database products LongReadLen 128 # change some fields from the default field type of char(128) # Only applies if Minivend is importing from ASCII file # If you set a field to a numeric type, you must set the # NUMERIC attribute Database products COLUMN_DEF "code=char(20) NOT NUL primary key" Database products COLUMN_DEF price=float, discount=float Database products COLUMN_DEF author=char(40), title=char(64) Database products COLUMN_DEF nontaxable=char(3) Database products NUMERIC price Database products NUMERIC discount
You must have mySQL,
DBI, and DBD::mysql completely installed and tested,
and have created the database minivend
for this to work. Permissions are difficult on mySQL -- if you have
trouble, try starting the mySQL daemon with safe_mysqld --skip-grant-tables &
for testing purposes.
To change to ODBC, the only changes required might be:
Database products DSN dbi:ODBC:TCP/IP localhost 1313 Database products ChopBlanks 1
The DSN setting is specific to your ODBC setup. The ChopBlanks setting takes care of the space-padding in Solid and some other databases -- it is not specific to ODBC. Once again, DBI, DBD::ODBC, and the and appropriate ODBC driver must be installed and tested.