Index: /pykota/trunk/contributed/mysql_history/history.sql
===================================================================
--- /pykota/trunk/contributed/mysql_history/history.sql (revision 2611)
+++ /pykota/trunk/contributed/mysql_history/history.sql (revision 2611)
@@ -0,0 +1,43 @@
+-- phpMyAdmin SQL Dump
+-- version 2.6.0
+-- http://www.phpmyadmin.net
+-- 
+-- Host: localhost
+-- Generation Time: Jan 10, 2006 at 02:24 PM
+-- Server version: 3.23.58
+-- PHP Version: 4.3.2
+-- 
+-- Database: `pykota`
+-- 
+
+-- --------------------------------------------------------
+
+-- 
+-- Table structure for table `history`
+-- 
+
+CREATE TABLE IF NOT EXISTS history (
+  id int(4) unsigned NOT NULL auto_increment,
+  jobid text NOT NULL,
+  username text NOT NULL,
+  printername text NOT NULL,
+  pgroups text NOT NULL,
+  jobsize int(4) NOT NULL default '0',
+  jobprice float NOT NULL default '0',
+  action text NOT NULL,
+  title text NOT NULL,
+  copies int(4) NOT NULL default '0',
+  options text NOT NULL,
+  printeroriginatinghostname text NOT NULL,
+  md5sum text NOT NULL,
+  precomputedjobsize int(4) NOT NULL default '0',
+  precomputedjobprice float NOT NULL default '0',
+  jobdate timestamp(14) NOT NULL,
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;
+
+-- 
+-- Dumping data for table `history`
+-- 
+
+INSERT INTO history VALUES (1, '23971', 'hyclak', 'print325', 'math-laser', 1, 0, 'ALLOW', 'mysql_history.py', 1, '', 'localhost', 'f5775c4bad32c999074e2eb5d8374aac', 1, 0, '20060110142024');
Index: /pykota/trunk/contributed/mysql_history/mysql_history.conf
===================================================================
--- /pykota/trunk/contributed/mysql_history/mysql_history.conf (revision 2611)
+++ /pykota/trunk/contributed/mysql_history/mysql_history.conf (revision 2611)
@@ -0,0 +1,6 @@
+[default]
+server: localhost
+username: pykota
+password: s3kr3t
+database: pykota
+table: history
Index: /pykota/trunk/contributed/mysql_history/README
===================================================================
--- /pykota/trunk/contributed/mysql_history/README (revision 2611)
+++ /pykota/trunk/contributed/mysql_history/README (revision 2611)
@@ -0,0 +1,14 @@
+This is a simple mysql history script contributed by 
+Matt Hyclak <hyclak@math.ohiou.edu>
+
+To use, place the mysql_history.conf file in your pykota config directory. 
+This is located in the pykota user's home directory, or as a last resort in 
+/etc/pykota. Modify the variables to match your setup.
+
+The mysql_history.py should be called from a posthook script. No variables need
+be passed to the script, as it extracts everything from the environment 
+variables set by Pykota.
+
+The history.sql file includes the SQL statements to create the database used
+by the mysql_history.py program. This can be extended fairly trivially if you 
+wish to capture extra data.
Index: /pykota/trunk/contributed/mysql_history/mysql_history.py
===================================================================
--- /pykota/trunk/contributed/mysql_history/mysql_history.py (revision 2611)
+++ /pykota/trunk/contributed/mysql_history/mysql_history.py (revision 2611)
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+import MySQLdb, pwd, string, sys
+from ConfigParser import *
+from os import environ
+
+try:
+	pykotauser = pwd.getpwnam("pykota")
+except KeyError:
+	pykotauser = None
+	confdir = "/etc/pykota"
+else:
+	confdir = pykotauser[5]
+
+configfile = confdir + "/mysql_history.conf"
+
+config = ConfigParser()
+config.read(configfile)
+mysqlserver = config.get("default", "server").strip()
+mysqluser = config.get("default", "username").strip()
+mysqlpass = config.get("default", "password").strip()
+mysqldb = config.get("default", "database").strip()
+mysqltable = config.get("default", "table").strip()
+
+try:
+	db = MySQLdb.connect(mysqlserver,mysqluser,mysqlpass,mysqldb)
+except:
+	print "Unable to connect to MySQL database."
+	sys.exit(1)
+
+cursor = db.cursor()
+
+cursor.execute("""INSERT INTO %s (id, jobid, username, printername, pgroups, 
+	jobsize, jobprice, action, title, copies, options, 
+	printeroriginatinghostname, md5sum, precomputedjobsize, 
+	precomputedjobprice) VALUES 
+	("", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")""" % 
+	(mysqltable, environ['PYKOTAJOBID'], environ['PYKOTAUSERNAME'], environ['PYKOTAPRINTERNAME'], environ['PYKOTAPGROUPS'], environ['PYKOTAJOBSIZE'],environ['PYKOTAJOBPRICE'], environ['PYKOTAACTION'], environ['PYKOTATITLE'],environ['PYKOTACOPIES'],environ['PYKOTAOPTIONS'],environ['PYKOTAJOBORIGINATINGHOSTNAME'],environ['PYKOTAMD5SUM'],environ['PYKOTAPRECOMPUTEDJOBSIZE'],environ['PYKOTAPRECOMPUTEDJOBPRICE']))
+
+cursor.close()
+
+# vim:tabstop=4
