Index  Up  >>  


A bit about text source files

MiniVend reads TAB-delimited text files to obtain your data. However, the text files are not the database. They are the source information for the database tables; when you change them, essentially you are placing text which will be imported into the database table.

Note the following directive:

    Database  products  products.txt   TAB

This says that the products table will obtain its source information from the file products.txt. What is done with it depends on the type of underlying database you are using. The different types:

GDBM
The database source file is checked to see if it is newer than the actual database file, which would be products.gdbm. If it is, then the database table is re-imported from the file.

You can change this behavior in a couple of ways. If you wish the file never to be imported unless the .gdbm file disappears, set the NoImport directive:

    NoImport  products

If you want it only to be imported at catalog start-up time, use the IMPORT_ONCE modifier:

    Database products IMPORT_ONCE 1

GDBM is the default type if you have GDBM_File Perl module installed (as it will be on Linux).

DB_File
The database source file is checked to see if it is newer than the actual database file, which would be products.db. If it is, then the database table is re-imported from the file.

You can change this behavior in the same way as with GDBM_File (above).

DB_File is the default type if you do not have the GDBM_File Perl module installed. This is typical on FreeBSD.

To explicitly specify DB_File as the type, you can specify it with a Database directive in catalog.cfg:

    Database  products  DB_FILE   1

DBI/SQL
If a file named products.sql is present in the same directory as products.txt the database table will not be imported from ASCII source. If there is no products.sql, then the following will occur:

DBI/SQL imports only happen at catalog configuration time.

  1. MiniVend will connect to the SQL database using the specified DSN. (DBI parameter meaning ``Database Source Name''.)

  2. The table will be dropped with ``DROP TABLE products;''. This will occur without warning!

  3. The table will be created. If there are COLUMN_DEF specifications in catalog.cfg, they will be used; otherwise the key (first field in the text file by default) will be created with a char(16) type and all other fields will be created as char(128). The table creation statement will be written to the error.log file.

  4. The text source file will be imported into the SQL database. MiniVend will place the data in as in the columns; you must take care of data typing yourself. This means that if you put ``none'' in a field, and it is defined as a numeric type, the database import will not succeed. If it does not, the catalog will not become active.

In-memory
Every time the catalog is configured, the products.txt file is imported into memory and forms the database. The database is not changed otherwise.

In-memory is the default type if there is no GDBM_File or DB_File Perl module installed; you can also specify it with:

   Database   products   MEMORY   1


Index  Up  >>