#
# This file is example of dictd configuration file
# consisting of one database implemented by DBI plugin.
# postgresql's driver is used
#
# It is assumed that SQL database consists of single table `dict'
#  with two columns: `hw' and `def'
#


database_plugin dictionary_name {
  # This section specifies the plugin.  The
  # `dictionary_name' specifies the name of the
  # dictionary.

  plugin "/usr/local/libexec/dictd/dictdplugin_dbi.so"
  data "\
driverdir       = \"/usr/lib/dbd/\"    \n\
drivername      = \"pgsql\"            \n\
\
option_host     = localhost            \n\
option_port     = 1234                 \n\
option_dbname   = SQL_server_database_name \n\
option_username = SQL_server_username      \n\
option_password = SQL_server_user_password \n\
\
query_define    = \"SELECT def         \
                    FROM dict          \
                    WHERE hw = '%q'\"  \n\
\
query_exact     = \"SELECT DISTINCT hw \
                    FROM dict          \
                    WHERE hw = '%q'\"  \n\
\
query_prefix    = \"SELECT DISTINCT hw \
                    FROM dict          \
                    WHERE position('%q' in hw)=1\" \n\
\
query_substring = \"SELECT DISTINCT hw \
                    FROM dict          \
                    WHERE position('%q' in hw) != 0\" \n\
\
query_suffix = \"SELECT DISTINCT hw    \
                 FROM dict             \
                 WHERE                 \
                   substring(hw, length(hw) - length('%q') + 1) = '%q'\" \n\
\
query_reverse = \"SELECT DISTINCT hw \
                 FROM dict          \
                 WHERE position('%q' in def) != 0\" \n\
"
}
