Difference between revisions of "Convert To Mysql"
From FusionPBX
(Created page with "== Conversion to MySQL == Get a sqlite dump by running: sqlite3 fusionpbx.db .dump > dumpfile.sql The following script converts a sqlite dump to mysql pretty well. Usage: ./scr...") |
(→Conversion to MySQL) |
||
Line 1: | Line 1: | ||
== Conversion to MySQL == | == Conversion to MySQL == | ||
+ | |||
+ | == This is a work in progress and still experimental == | ||
Get a sqlite dump by running: sqlite3 fusionpbx.db .dump > dumpfile.sql | Get a sqlite dump by running: sqlite3 fusionpbx.db .dump > dumpfile.sql | ||
The following script converts a sqlite dump to mysql pretty well. Usage: ./script.pl dumpfile.sql > mysql_dump.sql | The following script converts a sqlite dump to mysql pretty well. Usage: ./script.pl dumpfile.sql > mysql_dump.sql | ||
− | In addition to the script, replace all occurences of "NUMBER" to "NUMERIC". | + | In addition to the script, replace all occurences of "NUMBER" to "NUMERIC". '''Be careful that you only replace the correct occurrences of number''' |
<pre> | <pre> |
Latest revision as of 19:56, 1 February 2011
Contents
Conversion to MySQL
This is a work in progress and still experimental
Get a sqlite dump by running: sqlite3 fusionpbx.db .dump > dumpfile.sql
The following script converts a sqlite dump to mysql pretty well. Usage: ./script.pl dumpfile.sql > mysql_dump.sql In addition to the script, replace all occurences of "NUMBER" to "NUMERIC". Be careful that you only replace the correct occurrences of number
#! /usr/bin/perl while ($line = <>){ if (($line !~ /BEGIN TRANSACTION/) && ($line !~ /COMMIT/) && ($line !~ /sqlite_sequence/) && ($line !~ /CREATE UNIQUE INDEX/)){ if ($line =~ /CREATE TABLE \"([a-z_]*)\"(.*)/){ $name = $1; $sub = $2; $sub =~ s/\"//g; $line = "DROP TABLE IF EXISTS $name;\nCREATE TABLE IF NOT EXISTS $name$sub\n"; } elsif ($line =~ /INSERT INTO \"([a-z_]*)\"(.*)/){ $line = "INSERT INTO $1$2\n"; $line =~ s/\"/\\\"/g; $line =~ s/\"/\'/g; }else{ $line =~ s/\'\'/\\\'/g; } $line =~ s/([^\\'])\'t\'(.)/$1THIS_IS_TRUE$2/g; $line =~ s/THIS_IS_TRUE/1/g; $line =~ s/([^\\'])\'f\'(.)/$1THIS_IS_FALSE$2/g; $line =~ s/THIS_IS_FALSE/0/g; $line =~ s/AUTOINCREMENT/AUTO_INCREMENT/g; print $line; } }
Import the data into the fusionpbx database
mysql -u root -p fusionpbx < mysql_dump.sql
Edit the config.php file to point the system at mysql
$dbtype = 'mysql'; $dbhost = 'localhost'; $dbport = '3306'; $dbname = 'fusionpbx'; $dbusername = 'fusionpbx'; $dbpassword = 'jpdrmpdr';