Edgewall Software

Changes between Version 17 and Version 18 of SqLiteToMySql


Ignore:
Timestamp:
Feb 16, 2012, 7:38:05 AM (12 years ago)
Author:
kmenc15@…
Comment:

Write explicit tables for truncate in perl sqlite→mysql script

Legend:

Unmodified
Added
Removed
Modified
  • SqLiteToMySql

    v17 v18  
    127127None of the scripts here deal with quoting of ' characters caused by sqlite/mysql differences. Here is my perl script for sqlite to mysql migrate, which handles quoting very accurately:
    128128{{{
    129 print << 'EOF';
    130 BEGIN;
    131 TRUNCATE `attachment` ;
    132 TRUNCATE `auth_cookie` ;
    133 -- ############ more truncates here...
    134 EOF
    135 
    136 $inq=0;
    137 $del=0;
     129print "BEGIN;\n";
     130print "TRUNCATE `$_`;\n" for (qw(attachment auth_cookie cache component enum milestone node_change permission report
     131                                 repository revision session session_attribute system ticket ticket_change ticket_custom version wiki));
     132my ($inq,$del);
    138133sub qut { local $_=shift; ($inq ? (/'/ ? "\\" : ($inq=0,"'")) : "'".(/'/ ? '' : ($inq=1,''))).$_ }
    139 
    140134while (<>) {
    141135        $del=!/;/, next if ($del);
     
    148142        print;
    149143}
    150 print "COMMIT;"
     144print "COMMIT;\n"
    151145}}}