
FabForce::DBDesigner4

version 0.31

use FabForce::DBDesigner4;
my $designer = FabForce::DBDesigner4->new();
$designer->parsefile(xml => 'KESS.xml');
$designer->writeSQL('text_sql.sql',{ type => 'mysql' });

FabForce::DBDesigner4 is a module to analyse xml-files created by the Database-Design tool DBDesigner (Version 4) from FabForce (http://www.fabforce.net).
NOTICE: As of version 0.2 you can not parse sql files any longer. You just can parse xml files created by DBDesigner. And you can't create XML files!

FabForce::DBDesigner4 - Parse/Analyse XML-Files created by DBDesigner 4 (FabForce)

# create a new instance my $designer = FabForce::DBDesigner4->new();
parse the input file (XML - FabForce format )
# parse a xml-file $designer->parsefile(xml => 'KESS.xml');
print the structure into a sql-file
$designer->writeSQL('foo.sql');
# print "drop table statements"
$designer->writeSQL( 'foo.sql', { drop_tables => 1 } );
returns an array of table-objects
my @tables = $designer->getTables();
returns an array of CREATE statements. One element for each table.
my @creates = $designer->getSQL();
# get "drop table" statements in extra elements
my @creates = $designer->getSQL({ drop_table => 1 });

Each table is an object which contains information about the columns, the relations and the keys.
Methods of the table-objects
# set the tablename
$table->name('tablename');
# get the tablename
my $name = $table->name();
# set the tablecolumns
my @array = ({'column1' => ['int','not null']});
$table->columns(\@array);
# get the columns
print $_,"\n" for($table->columns());
# get datatype of n-th column (i.e. 3rd column) my $datatype = $table->columnType(3);
# get info about n-th column (i.e. 4th column) print Dumper($table->columnInfo(4));
# maps column information to hash (needed for columns())
my @columns = ('col1 varchar(255) primary key', 'col2 int not null');
my @array = $table->stringsToTableCols(@columns);
# add the tablecolumn my $column = ['column1','int','not null']; $table->addColumn($column);
# set relations my @relations = ([1,'startTable.startCol','targetTable.targetCol']); $table->relations(\@relations); # get relations print $_,"\n" for($table->relations());
$table->addRelation([1,'startTable.startCol','targetTable.targetCol']);
# removes a relation (i.e. 2nd relation) $table->removeRelation(2);
# set the primary key $table->key(['prim1']); # get the primary key print "the primary key contains these columns:\n"; print $_,"\n" for($table->key());

This module requires XML::Twig

This module is still in development so feel free to contact me and send me bugreports or comments on this module.

XML::Twig and IO::File

Renee Baecker, <module@renee-baecker.de>

Copyright (C) 2005 - 2011 by Renee Baecker
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
These conditions apply for all files in this package.

Renee Baecker <module@renee-baecker.de>

This software is Copyright (c) 2010 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0