You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by pa...@apache.org on 2004/03/01 05:07:30 UTC

svn commit: rev 6941 - incubator/spamassassin/trunk/sql

Author: parker
Date: Sun Feb 29 20:07:29 2004
New Revision: 6941

Added:
   incubator/spamassassin/trunk/sql/awl_pg.sql
   incubator/spamassassin/trunk/sql/userpref_mysql.sql
      - copied unchanged from rev 6938, incubator/spamassassin/trunk/sql/spamassassin.sql
   incubator/spamassassin/trunk/sql/userpref_pg.sql
Removed:
   incubator/spamassassin/trunk/sql/spamassassin.sql
Modified:
   incubator/spamassassin/trunk/sql/README
   incubator/spamassassin/trunk/sql/README.awl
   incubator/spamassassin/trunk/sql/README.bayes
Log:
PR3095: Update sql documentation to include PostgreSQL examples and instructions, parts from Feargal Reilly

Modified: incubator/spamassassin/trunk/sql/README
==============================================================================
--- incubator/spamassassin/trunk/sql/README	(original)
+++ incubator/spamassassin/trunk/sql/README	Sun Feb 29 20:07:29 2004
@@ -15,7 +15,7 @@
 SpamAssassin will check the global configuration file (ie. any file matching
 /etc/mail/spamassassin/*.cf) for the following settings:
 
-  user_scores_dsn		DBI:driver:database:hostname[:port]
+  user_scores_dsn		DBI:driver:connection
   user_scores_sql_username	dbusername
   user_scores_sql_password	dbpassword
   user_scores_sql_table         tablename
@@ -23,22 +23,43 @@
 The first option, user_scores_dsn, describes the data source name that will be
 used to create the connection to your SQL server.  It MUST be in the format
 as listed above.  <driver> should be the DBD driver that you have installed
-to access your database. <database> must be the name of the database that you
-created to store the user preference table. <hostname> is the name of the host
-that contains the SQL database server. <port> is the optional port number where
-your database server is listening.
+to access your database.
+<connection> can differ depending on which database you are using.
+
+For MySQL, connection should take the format
+
+  database:hostname[:port]
+
+<database> must be the name of the database that you created to store the user
+preference table. <hostname> is the name of the host that contains the SQL
+database server. <port> is the optional port number where your database server
+is listening.
 
   user_scores_dsn		DBI:mysql:spamassassin:localhost
 
 Would tell SpamAssassin to connect to the database named spamassassin using
 MySQL on the local server, and since <port> is omitted, the driver will use the
-default port number.  The other two required options tells SpamAssassin to use 
-the defined username and password to establish the connection.
+default port number.
+
+For PostgreSQL, connection should take the following format:
+
+  dbname=database;[host=hostname;[port=port;]
+  
+  user_scores_dsn               DBI:Pg:dbname=spamassassin;host=localhost
+
+would do the same as the previous example.
+
+For additional information, please refer to the DBD::* documentation
+for your particular driver.
+
+If the user_scores_dsn option does not exist, SpamAssassin will not
+attempt to use SQL for retrieving users' preferences. Note that this
+will NOT look for test rules, only local scores, whitelist_from(s),
+required_score, and auto_report_threshold.
+
+The other two required options tells SpamAssassin to use the defined
+username and password to establish the connection.
 
-If the user_scores_dsn option does not exist, SpamAssassin will not attempt
-to use an SQL for retrieving users' preferences. Note that this will NOT look
-for test rules, only local scores, whitelist_from(s), required_score, and
-auto_report_threshold.
 
 Requirements
 ------------
@@ -81,13 +102,12 @@
 the default table, you must first create a database, and a username/password
 that can access that database.
 
-To create a database, if one does not already exist, see "Creating A Database
-In MySQL" below.
+To create a database, if one does not already exist, see "Creating A Database"
+below.
 
+To install the table to a mysql database, use the following command:
 
-To install the table, use the following command:
-
-mysql -h <hostname> -u <adminusername> -p <databasename> < spamassasin.sql
+mysql -h <hostname> -u <adminusername> -p <databasename> < userpref_mysql.sql
 Enter password: <adminpassword>
 
 This will create the following table:
@@ -101,6 +121,12 @@
   INDEX (username)
 ) TYPE=MyISAM;
 
+For PostgreSQL, use the following command:
+
+psql -U <username> -f userpref_pg.sql <databasename>
+
+This will create a table similar to above.
+
 Once you have created the database and added the table, just add the required
 lines to your global configuration file (local.cf).  Note that you must be
 running spamc/spamd in order for this to work, and the current username must
@@ -123,11 +149,11 @@
 the SQL table instead of /etc/passwd.  See "man spamd".
 
 
-Creating A Database In MySQL
-----------------------------
+Creating A Database 
+-------------------
 
-Here's the command to create a database, and user/password pair to access
-it, for MySQL:
+Here's the command to create a MySQL database, and user/password pair to access
+it:
 
 mysql -h <hostname> -u <adminusername> -p
 Enter password: <adminpassword>
@@ -138,6 +164,13 @@
 mysql> quit
 
 
+To create the database for PostgreSQL, with a username/password:
+
+psql -U <adminuser> template1
+template1=# CREATE USER <username> PASSWORD '<password>';
+template1=# CREATE DATABASE <databasename> OWNER = <username>;
+
+
 Testing SpamAssassin/SQL
 ------------------------
 
@@ -169,16 +202,3 @@
 NB:  This should be considered BETA, and the interface, schema, or overall
 operation of SQL support may change at any time with future releases of SA.
 ******
-
-
-PHP Interface
--------------
-
-This can be downloaded from http://spamassassin.org/devel/ , called
-"php-sa-mysql-n.n"  where n.n is the version number.
-
-
-Please send any comments to jengland /at/ enetis.net .
-
-Justin England
-

Modified: incubator/spamassassin/trunk/sql/README.awl
==============================================================================
--- incubator/spamassassin/trunk/sql/README.awl	(original)
+++ incubator/spamassassin/trunk/sql/README.awl	Sun Feb 29 20:07:29 2004
@@ -46,6 +46,8 @@
 
 user_awl_sql_table           awl
 
+For an example of connecting to a PostgreSQL database, see the README file.
+
 Requirements
 ------------
 
@@ -81,8 +83,8 @@
 
 Included is a default table that can be safely used in your own setup.  To use
 the default table, you must first create a database, and a username/password
-that can access that database.  (See "Creating A Database In MySQL", in
-"sql/README", if you don't have a suitable database ready.)
+that can access that database.  (See "Creating A Database", in "sql/README", if
+you don't have a suitable database ready.)
 
 To install the table, use the following command:
 
@@ -100,6 +102,9 @@
   PRIMARY KEY  (username,email,ip)
 ) TYPE=MyISAM;
 
+For PostgreSQL, use the following:
+
+psql -u <username> -f awl_pg.sql <databasename>
 
 Once you have created the database and added the table, just add the required
 lines to your global configuration file (local.cf).  Note that you

Modified: incubator/spamassassin/trunk/sql/README.bayes
==============================================================================
--- incubator/spamassassin/trunk/sql/README.bayes	(original)
+++ incubator/spamassassin/trunk/sql/README.bayes	Sun Feb 29 20:07:29 2004
@@ -34,6 +34,8 @@
 database  server.  <port> is the optional port number where your
 database server is listening.
 
+For an example of connection to PostgreSQL, see the main README file.
+
 In addition to the global configuration directives there is a user
 preference:
 
@@ -43,6 +45,7 @@
 data in the database.  This could be used to group users together to
 share bayesian filter data.
 
+
 Requirements
 ------------
 
@@ -77,13 +80,17 @@
 
 This assumes that you have already created a database for use with
 spamassassin and setup a username/password that can access that database.
-(See "Creating A Database In MySQL", in "sql/README", if you don't have a
-suitable database ready.)
+(See "Creating A Database", in "sql/README", if you don't have a suitable
+database ready.)
 
 To install the tables using the included example, use the following command:
 
 mysql -h <hostname> -u <adminusername> -p databasename < bayes_mysql.sql
 Enter password: <adminpassword>
+
+To install the tables for PostgreSQL, use:
+
+psql -u <username> -f bayes_pg.sql <databasename>
 
 Once you have created the database and added the tables, just add the
 required lines to your global configuration file (local.cf).

Added: incubator/spamassassin/trunk/sql/awl_pg.sql
==============================================================================
--- (empty file)
+++ incubator/spamassassin/trunk/sql/awl_pg.sql	Sun Feb 29 20:07:29 2004
@@ -0,0 +1,8 @@
+CREATE TABLE awl (
+  username varchar(100) NOT NULL default '',
+  email varchar(200) NOT NULL default '',
+  ip varchar(10) NOT NULL default '',
+  count bigint default '0',
+  totscore float default '0'
+);
+CREATE UNIQUE INDEX awl_pkey ON awl (username,email,ip);

Added: incubator/spamassassin/trunk/sql/userpref_pg.sql
==============================================================================
--- (empty file)
+++ incubator/spamassassin/trunk/sql/userpref_pg.sql	Sun Feb 29 20:07:29 2004
@@ -0,0 +1,7 @@
+CREATE TABLE userpref (
+  prefid bigserial NOT NULL unique primary key,
+  username varchar(100) NOT NULL,
+  preference varchar(30) NOT NULL,
+  value varchar(100) NOT NULL
+);
+CREATE INDEX userpref_username_idx ON userpref(prefid);