Find file
Fetching contributors…
Cannot retrieve contributors at this time
124 lines (99 sloc) 3.69 KB
__NAME__ purpose
register existing database table for use with Interchange
__END__
__NAME__ synopsis
<arg choice='plain'><replaceable>table_name</replaceable></arg>
<arg choice='plain'><replaceable>table_source_file</replaceable></arg>
<arg choice='plain'><replaceable>table_type</replaceable></arg>
<sbr/>
<arg choice='plain'><replaceable>table_name</replaceable></arg>
<arg choice='plain'><replaceable>attribute</replaceable></arg>
<arg choice='plain'><replaceable>value</replaceable></arg>
__END__
__NAME__ see also
TableRestrict,data,DatabaseDefault
__END__
__NAME__ description
</para><para>
The directive registers a database table for use with &IC;.
<literal>table_name</literal> specifies an arbitrary name &mdash; name
that will be used to refer to the table within &IC;. Names can be composed
of alphanumeric characters including underscore, and we recommend they're in
all lower- or upper-case.
</para><para>
<literal>source_file</literal> specifies the initial database text
source file, and <literal>type</literal> specifies database format.
</para><para>
For more about &IC; and databases, and supported formats, see &glos-database;
glossary entry.
__END__
__NAME__ notes
In &IC;, words <literal>table</literal> and <literal>database</literal>
are used to refer to the same thing &mdash; database table.
</para><para>
Defining databases on an &IC; (global) level
<emphasis role='bold'>won't work</emphasis>. If you want to share
databases among catalogs, define them in each &ccf; separately (possibly
by including the generic file with &conf-Database; definitions).
__END__
__NAME__ example: Default, most basic products database
<programlisting>
Database products products.txt TAB
</programlisting>
__END__
__NAME__ example: Simple definition of a CSV-style database source format
<programlisting>
Database reviews reviews.txt CSV
</programlisting>
__END__
__NAME__ example: Automatically configure all tables from an existing PostgreSQL database
<programlisting>
DatabaseAutoIgnore ^sql_
DatabaseAuto __SQLDSN__
NoImportExternal Yes
</programlisting>
For further discussion, see &conf-DatabaseAuto;.
__END__
__NAME__ example: Definition of a Postgres database table
<programlisting>
#
# Required for PostgreSQL
#
Require module DBI
Require module DBD::Pg
Variable SQLDSN dbi:Pg:dbname=database_name
Variable SQLUSER username
Variable SQLPASS password
Variable SOME_DATABASE 1
&lt;ParseVariables Yes&gt;
DatabaseDefault USER __SQLUSER__
DatabaseDefault PASS __SQLPASS__
DatabaseDefault NO_ASCII_INDEX 1
Message -i -n Using PostgreSQL, DSN=__SQLDSN__...
#
# Individual database table definitions
#
Database table_name table_name.txt __SQLDSN__
&lt;/ParseVariables&gt;
#
# Optional table descriptions
#
Database table_name LENGTH_EXCEPTION_DEFAULT truncate_log
Database table_name DEFAULT_TYPE varchar(255)
Database table_name KEY sku
Database table_name HIDE_FIELD inactive
Database table_name COLUMN_DEF "sku=varchar(64) NOT NULL PRIMARY KEY"
Database table_name COLUMN_DEF "description=varchar(128)"
Database table_name COLUMN_DEF "price=varchar(12)"
Database table_name INDEX description
Database table_name INDEX price
</programlisting>
For the above example to work, you will need file <literal><replaceable>table_name.txt</replaceable></literal> present within &conf-ProductDir;, containing the initial data set for the table. If there's no initial data set and the table should be empty, the file still needs to contain a single line with three column names, separated by a TAB:
<programlisting>
sku description price
</programlisting>
__END__
__NAME__ missing
Examples for each DB type supported (Oracle, Mys,... )
List of all keys that can occur in a specification
__END__