Project

General

Profile

ETL: extract, transform, load ยป etl.xml

Scriptella code - Bruce Ingalls, 2009-03-11 17:12

 
1
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
2
<etl>
3
    <description>Convert Bugzilla database to Redmine</description>
4
    <properties>driver=com.mysql.jdbc.Driver</properties>
5
    <connection id="bugzilla" driver="mysql" url="jdbc:mysql://localhost:3306/bugzilla" user="root" password=""/>
6
    <connection id="text" driver="text" url="file:///tmp/bug2red.sql"/>
7
    
8
    <!-- Changes password to same as login id. Assumes Redmine on mysql uses sha1. Otherwise, set blank. -->
9
    <!-- Change the mail column for your site -->
10
    <query connection-id="bugzilla">
11
      SELECT
12
       login_name,
13
       SHA1(login_name) AS hashed_password,
14
       LEFT(realname, locate(' ', realname)) AS firstname,
15
       SUBSTRING(realname, locate(' ', realname)) AS lastname,
16
       login_name AS mail
17
      FROM profiles;
18
      <script connection-id="text">
19
       INSERT INTO users (login,hashed_password,firstname,lastname,mail) VALUES ('$1','$2','$3','$4','$5');
20
      </script>
21
    </query>
22
    
23
    <query connection-id="bugzilla">
24
      SELECT
25
		bug_id AS id,
26
		assigned_to AS assigned_to_id,
27
		reporter AS author_id,
28
		creation_ts AS created_on,
29
		short_desc AS description,
30
		deadline AS due_date,
31
		keywords AS subject
32
      FROM bugs;
33
      <script connection-id="text">
34
		INSERT INTO issues (id,tracker_id,project_id,assigned_to_id,author_id,created_on,description,due_date,subject) VALUES ('$1','$1','1','$2','$3','$4','$5');
35
      </script>
36
    </query>
37

    
38
	<!-- Bugzilla name is 64 chars. Redmine uses 30 chars -->    
39
    <query connection-id="bugzilla">
40
      SELECT DISTINCT LEFT(name, 30) AS name FROM series_categories;
41
      <script connection-id="text">INSERT INTO projects (name) VALUES ('$1');</script>
42
    </query>
43
    
44
</etl>
    (1-1/1)