NAME
DBIx::ContentChecksum - Compare database content
SYNOPSIS
use DBIx::ContentChecksum;
my $oDB_Comparison = db_comparison->new($dbh1,$dbh2);
$oDB_Comparison->compare;
DESCRIPTION
DBIx::ContentChecksum takes two database handles and performs a very low level comparison of their table content.
METHODS
- new($dbh1,$dbh2)
-
You must pass two database handles at initialisation, and each database must be the same type.
- compare
-
Performs the comparison. Calls the methods compare_table_lists and compare_row_counts. In scalar context, returns a hashref of the differences found. In void context this method outputs a report to STDOUT.
- compare_table_lists
-
Simple comparison of the table names. Returns true if no differences are found, otherwise returns undef. An array ref of tables unique to each database:host can be recovered with get_differences(), using the hash key
'Tables unique to [db name:host]'
- compare_row_counts
-
Comparison of the row counts from each table. Can pass a table name, or will compare all tables. Returns true if no differences are found, otherwise returns undef. An array ref of tables with different row counts can be recovered with get_differences(), using the hash key
'Row count'
. - get_primary_keys($table,$dbh)
-
Returns the primary keys (in key order) for the given table/database, either as a list or as a comma separated string.
- get_differences
-
Returns a hashref of differences between the two databases, where keys are the source of the difference, and values are an array ref of the differences found (see comparison methods above for details).
- get_tables
-
Returns a table list. Before a comparison has been run, this method will return a 2D list of tables in list context, or just a list of tables in database1 in scalar context;
my @aList = $oDB_Comparison->get_tables; # returns (['table1','table2',etc],['table1','table2',etc])
However, after a comparison has been run, only those tables that are the same for the comparison are returned by a subsequent call to get_tables().
FUTURE DEVELOPMENT
At some point (probably when I need to) I intend to expand this module to perform row-by-row comparison.
AUTHOR
Christopher Jones, Gynaecological Cancer Research Laboratories, UCL EGA Institute for Women's Health, University College London.
c.jones@ucl.ac.uk
COPYRIGHT AND LICENSE
Copyright 2008 by Christopher Jones, University College London
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.