| 124 | |
| 125 | ---- |
| 126 | |
| 127 | None 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: |
| 128 | {{{ |
| 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; |
| 138 | sub qut { local $_=shift; ($inq ? (/'/ ? "\\'\\" : ($inq=0,"'")) : "'".(/'/ ? '' : ($inq=1,''))).$_ } |
| 139 | |
| 140 | while (<>) { |
| 141 | $del=!/;/, next if ($del); |
| 142 | s/^(COMMIT|BEGIN TRANSACTION);//mg; |
| 143 | $del=1, next if (/^CREATE (TABLE|INDEX)/); |
| 144 | s/INSERT INTO "([^"]+)"/INSERT INTO `$1`/g; |
| 145 | s/\\/\\\\/g; |
| 146 | s/'(.|$)/qut($1)/ge; |
| 147 | s/(INSERT INTO `milestone` .*),0,NULL/$1,NULL/g; |
| 148 | print; |
| 149 | } |
| 150 | print "COMMIT;" |
| 151 | }}} |