package SQL::Translator::Producer::Dumper;
# -------------------------------------------------------------------
-# $Id: Dumper.pm,v 1.6 2004-07-14 19:37:41 kycl4rk Exp $
+# $Id$
# -------------------------------------------------------------------
-# Copyright (C) 2002-4 SQLFairy Authors
+# Copyright (C) 2002-6 SQLFairy Authors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
use Data::Dumper;
-$VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/;
sub produce {
my $t = shift;
--mysql-loadfile Create MySQL's LOAD FILE syntax, not INSERTs
--no-comments Suppress comments
--skip=t1[,t2] Comma-separated list of tables to skip
- --skiplike=regex Comma-separated list of tables to skip
+ --skiplike=regex Regular expression of table names to skip
+ --takelike=regex Regular expression of table names to take
USAGE
exit(0);
field_name = field.name;
fname_len = field.name.length;
max_field = fname_len > max_field ? fname_len : max_field;
- types.$field_name = field.data_type.match( '(char|str|long|text|enum)' )
+ types.$field_name = field.data_type.match( '(char|str|long|text|enum|date)' )
? 'string' : 'number';
field_names.push( field_name );
END;
print "TRUNCATE TABLE $table_name;\n";
}
- my $data = $db->selectall_arrayref(
- 'select ' . join(', ', @{ $table->{'fields'} } ) . " from $table_name",
- { Columns => {} }
- );
+ my $sql =
+ 'select ' . join(', ', @{ $table->{'fields'} } ) . " from $table_name"
+ ;
+ my $sth = $db->prepare( $sql );
+ $sth->execute;
- for my $rec ( @{ $data } ) {
+ while ( my $rec = $sth->fetchrow_hashref ) {
my @vals;
for my $fld ( @{ $table->{'fields'} } ) {
my $val = $rec->{ $fld };
=head1 AUTHOR
-Ken Y. Clark E<lt>kclark@cpan.orgE<gt>.
+Ken Youens-Clark E<lt>kclark@cpan.orgE<gt>.
=cut