Menu

Tree [57d039] master add-log4perl /
 History

HTTPS access


File Date Author Commit
 DBIWrapper 2016-09-14 James A. Pattie James A. Pattie [f6d2e9] Optimizing date related time code.
 debian 2018-12-20 James A. Pattie James A. Pattie [d50207] Improved error output so sp_hints array is incl...
 t 2019-11-05 James A. Pattie James A. Pattie [57d039] [15] Adding support for the sql log files to be...
 .gitignore 2016-08-22 James A. Pattie James A. Pattie [6a953d] adding .gitignore
 Changes 2011-12-16 pcxuser pcxuser [c70746] * Adding debian/postinst to make sure the /var/...
 DBIWrapper.pm 2019-11-05 James A. Pattie James A. Pattie [57d039] [15] Adding support for the sql log files to be...
 LICENSE 2005-06-17 pcxuser pcxuser [676d5e] Bumped release info. Added the getID() method ...
 MANIFEST 2017-05-17 James A. Pattie James A. Pattie [61889d] Remove the explicit references to META.yml and ...
 Makefile.PL 2017-05-17 James A. Pattie James A. Pattie [edfe83] Updating the MANIFEST file and adding the MYMET...
 README 2019-09-11 James A. Pattie James A. Pattie [1cc346] [#13] Adding support for logging to STDOUT for ...
 dbi_wrapper.spec 2003-08-26 pcxuser pcxuser [634a8f] Fixing rpm build issues and making updated pack...
 parse_test.pl 2002-03-18 pcxuser pcxuser [7d344f] Added a new XML string test for the error docum...
 test.pl 2017-05-15 James A. Pattie James A. Pattie [f05270] * Tweaking the test.pl that gets run on insta...
 testing_db.mysql 2005-06-17 pcxuser pcxuser [676d5e] Bumped release info. Added the getID() method ...
 testing_db.pgsql 2005-06-17 pcxuser pcxuser [676d5e] Bumped release info. Added the getID() method ...

Read Me

DBIWrapper README
Created by James Pattie, Xperience, Inc., 11/02/2000
http://www.pcxperience.com/
mailto:pcxuser@sf.net

This module allows you to abstract working with DBI databases so that
the normal program just instantiates the wrapper, specifies the database, etc.
and then calls read or write on it to work with the database.  The programmer
will still need to know how DBI returns data, etc. but won't have to work with
the setup and exection code directly.

Needed modules: DBI, DBD-{Database name}
Recommended modules: XML::LibXML

Installation:
  untar the distribution: tar xvzf dbi_wrapper-{VERSION}.tar.gz
  perl Makefile.PL
  make
  make test
  su (if not root)
  make install
  touch /var/log/dbiwrapper-sql-statements.log
  touch /var/log/dbiwrapper-sql-statements-start.log
  touch /var/log/dbiwrapper-sql-statements-stop.log
  touch /var/log/dbiwrapper-long-running-sql.log
  chmod 0666 /var/log/dbiwrapper-sql-statements.log
  chmod 0666 /var/log/dbiwrapper-sql-statements-start.log
  chmod 0666 /var/log/dbiwrapper-sql-statements-stop.log
  chmod 0666 /var/log/dbiwrapper-long-running-sql.log

To test the program (make test), you need to create a test database called
testing_db.  For PostgreSQL you would do:
	createdb testing_db
	psql testing_db < testing_db.pgsql

If you are doing this as root, you should su to the postgres user so that the
database is created owned by postgres.

For MySQL:
  mysqladmin -p create testing_db
  mysql -p testing_db
    source testing_db.mysql

  Modify the test.pl script to use mysql instead of Pg.


Note:  As of version 0.16 XML output is now possible via the readXML method.
This will return a valid XML document with the result of your SELECT statement
or the error that was encountered.

As of version 0.17, you can parse the XML document created by readXML
via the DBIWrapper::XMLParser module.  It depends on XML::LibXML.
  libxml2 2.4.11
  File-Temp 0.12
  XML::SAX 0.03
  XML::LibXML 1.31

Note: As of version 0.19, you can optionally call the read, readXML, write,
setError methods by just passing in the value (if only dealing with one argument
otherwise you still have to pass by name.  For read, readXML and write, I assume
the single argument is the sql string to execute.

Note: As of version 0.20, there are now helper methods to convert boolean values
back and forth between what DBI is expecting and a more user readable format.
1 <=> true, 0 <=> false.

Note: As of version 0.22, you can get the ID of the just inserted row by calling
getID().  See the manpage for PostgreSQL specific implementation details.

Sybase is also now a supported database backend.

Note: As of version 0.26 all sql statements are logged into 
/var/log/dbiwrapper-sql-statements.log.  The debian package will make sure this
file exists and is world writable (mode 0666).  You will need to configure
log rotation of this file per your policies.  Make sure the file is world writable
again by touching it into existance after you rotate it and set the permissions again.
You also need to deal with /var/log/dbiwrapper-long-running-sql.log.

NOTE: As of version 0.26-5 the log format has been tweaked to include human
readable versions of the timestamps and to include the server/dbHost and dbName values.

NOTE: As of version 0.27-1 the log format has been modified again to include millisecond
level granularity and uniquely identify each line so you can correlate from the new
-start.log and -stop.log log files to determine durations and the full sql that was
executed at that time.  This requires DateTime::HiRes and Digest::SHA being available.
Make sure you have created these log files and chmod 0666 them otherwise non-root
users will not be able to create/append them and your scripts will die.

NOTE: As of version 0.34 you can now specify 'STDOUT' for each log file and specify a custom
prefix to identify the sql statements, long running sql statements and the start and stop log entries.