1.1. Text Source Files
Interchange reads delimited text files to obtain its initial data. However, the text files are not the database. They are the source information for the database tables.
By default, all database source files are located in the products subdirectory of the catalog directory. The main products database is in the products/products.txt file in the supplied demo catalog.
Note: If you are using one of the internal database methods, any changes made to the ASCII source file will be reflected in the database in the next user session. If the product database contains less than a thousand records, updates will be instantaneous. If the product database is larger, updates will take longer. Use the NoImport reference tag to stop auto updating.
In the following configuration directive:
Database products products.txt TAB
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 being used. The different types and their behavior are described below:
The database source file is checked to see if it is newer than the actual database file, products.gdbm. If it is, the database table is re-imported from the file.
This behavior can be changed in a few ways. If files should not be imported unless the .gdbm file disappears, set the NoImport directive:
If the database source file is only to be imported at catalog start-up time, use the IMPORT_ONCE modifier:
Database products IMPORT_ONCE 1
GDBM is the default database type if the GDBM_File Perl module is installed (as it is on LINUX).
The database source file is checked to see if it is newer than the actual database file, products.db. If it is, the database table is re-imported from the file. You can change this behavior in the same way as GDBM_File, described above.
DB_File is the default database type if the GDBM_File Perl module is not installed. This is common on FreeBSD. To specify DB_File as your database type, set it in catalog.cfg with a Database directive:
Database products DB_FILE 1
If a file named products.sql is in the same directory as products.txt, the database table will not be imported from the ASCII source. If there is no products.sql, the following will occur:
DBI/SQL imports will only happen at catalog configuration time.
Interchange will connect to the SQL database using the specified DSN. (DBI parameter meaning "Database Source Name".)
The table will be dropped with "DROP TABLE products;". This will occur without warning. NOTE: This can be prevented in several ways. See NoImport External or the SQL documentation for more information.
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.
The text source file will be imported into the SQL database. Interchange will place the data in the columns. Data typing must be user-configured. This means that if "none" is placed in a field, and it is defined as a numeric type, the database import will not succeed. And if it does not succeed, the catalog will not become active.
Every time the catalog is configured, the products.txt file is imported into memory and forms the database. Otherwise, the database is not changed. The in-memory database is the default database if there is no GDBM_File or DB_File Perl module installed; specify it with:
Database products MEMORY 1