Edgewall Software

Changes between Version 2 and Version 3 of SqLiteToMySql


Ignore:
Timestamp:
May 5, 2007, 12:14:34 AM (17 years ago)
Author:
anonymous
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • SqLiteToMySql

    v2 v3  
    3535cat trac.mysql.sql trac.sqlite.sql.dataonly > trac.sql 
    3636    }}}
     37
     38----
     39
     40An alternatice to the cleansql above (that works a bit better):
     41{{{
     42
     43$ cat cleansql.py
     44#!/usr/bin/env python
     45
     46import sys
     47import re
     48
     49file = sys.stdin.read()
     50file = re.sub(r'(CREATE (TABLE|INDEX)[^;]*|COMMIT|BEGIN TRANSACTION);', '', file)
     51file = re.sub(r'INSERT INTO "([^"]+)"', lambda m: 'INSERT INTO `%s`' % m.groups(1), file)
     52sys.stdout.write(file)
     53
     54$ cat trac.sqlite.sql | ./cleansql.py > trac.sqlite.sql.dataonly
     55}}}