How to migrate Trac from SQLite database to MySQL database

Posted under Joomla!, application configuration, configuration, google by perry on Monday 14 July 2008 at 15:31 pm

I’ve been Googling for a solution on how to get Trac and Joomla! to work together without too much work. The best thing would be a Joomla! Trac bridge, but I’ve not succeeded  in finding something like that. I’ve found some partly information about how to get Joomla! authenticated users to be accepted by Trac as authenticated but nothing about how to get Joomla! and Trac to share their user database. So I started poking around with different Trac settings and I suddenly found that Mandriva Linux had a package named trac-mysql which makes Trac capable of connecting to a MySQL database instead of a SQLite database so I started to search for a way to migrate from SQLite to MySQL and I got several hits on Google but as all you guys searching for things regarding Trac on Google is almost 99% pointless since it will show a hit for every Trac powered site in the world which is open for web crawlers. But after a couple of misses on the first page of hits I found one: http://trac.edgewall.org/wiki/SqLiteToMySql on Tracs own homepage :$ Why didn’t I just start searching there you can ask, but I thought I had read every possible page both in my local Trac setup and Tracs main page which wasn’t correct.

First:

cd /this/is/the/trac/project/directory
sqlite db/trac.db .dump > trac.sql

The by putting this into a file, clearsql.py:

#!/usr/bin/env python

import sys
import re

file = sys.stdin.read()
file = re.sub(r'(CREATE (TABLE|INDEX)[^;]*|COMMIT|BEGIN TRANSACTION);’, ”, file)
file = re.sub(r’INSERT INTO “([^"]+)”‘, lambda m: ‘INSERT INTO `%s`’ % m.groups(1), file)
sys.stdout.write(file)

And executing:

./clearsql.py trac.sql > mysql.ready.sql

Then I just downloaded this file to my workstation and imported it into MySQL with phpMyAdmin

Then I had to edit the Trac configuration file to work against the MySQL database:

database = mysql://username:password@hostname/databasename

And then I must had a ton of luck since it just worked.. ;)

And now I’m working on getting this data into a Joomla! Component, JoomTrac(or something like that) , I’ve already made a mod_trac_tickets module that lists the xx last tickets from the Trac ticket table. The module is done, but I’m also in need of a component for this so that users can submit tickets through the Joomla! interface instead of giving them access to the Trac system which is for project developers only, at least in this project. And if I’m productive during the summer I should manage to get a page for all the mandatory “pages” in Trac: Wiki, Timeline, Roadmap, Browser, Tickets and maybe even the search page, or make a mambot for that so that if you search in the com_search of the Joomla! site you get results from the Trac system as well.

proof of concept

A proof of concept image grabbed from my development server.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment



Design & Coding Knut-Perry G Brumoen from bytt.no & p-ds.no
Sign up for PayPal and start accepting credit card payments instantly.
l33tsig signature for perry