Edgewall Software

Version 2 (modified by anonymous, 17 years ago) ( diff )

a little suggestion for automation of sql structure cleaning

Convert Trac DB, from SQLite to MySQL

This is a copy from the mailing list …

% echo ".dump" | sqlite trac.db > trac.sql
% mysql tracdb < trac.sql

There could be syntax errors that would have to be manually fixed in the file trac.sql.

  1. Use trac-admin initenv to create the database structure
  2. Use mysqldump —no-data to dump the database structure into trac.mysql.sql
  3. Use sqlite .dump to dump the structure + data from sqlite into trac.sqlite.sql (unfortunately there's no option to only dump the data).
  4. Remove all the structure ('create table' and 'create index') from trac.sqlite.sql You could use this simple perl script:
    $ cat cleansql
    #!/usr/bin/env perl
    
    while (<>) {
      $i = $i . $_;
    }
    
    $i =~ s/^CREATE.*?\);$//smgi;
    
    print $i;
    
    # NEOF
    
    $ ./cleansql trac.sqlite.sql >  trac.sqlite.sql.dataonly
    
  5. Concatenate trac.mysql.sql and trac.sqlite.sql.dataonly into trac.sql
    cat trac.mysql.sql trac.sqlite.sql.dataonly > trac.sql  
    
Note: See TracWiki for help on using the wiki.