Medvedb - MEDium Visualization Environment for DataBases
Using XML firepower
use medvedb; my $interface = new medvedb; $interface->cast_spell('desrciption.xml','application');
Using Perl warhammer
use medvedb; my $interface = new medvedb; $interface->config({ -db_user => 'dbuser', -db_host => 'localhost', -db_database => 'mydatabase', -db_table => 'mytable', -db_default_order => 'name', -db_default_action => 'show' }); $interface->dbconnect(); my $order = $interface->getorder();
print $interface->htmlheader(); my %show = ( -db_view => { ID => ['id', 0], Name => ['name', 1], }, -view_select=> $order, -act_sort=> "<SELF_URL>?order=", -act_view=> "<SELF_URL??action=full&select=", ); print $interface->print_view({'show' => \%show}); print $interface->htmlend; $interface->dbdisconnect;
Medvedb module simplify building web and GUI* applications for access to database. Programmer or user simple specify content of database and Medvedb builds interace. There are some implicit rules for building interface so user do not need to tell everything about database. It the interace is not good user may specify more details.
There are two ways how to specify the interface:
1. Use Perl hash specification - good for programmer's but too complicated for normal user.
2. Use XML specification - good for normal user, but it's little bit weaker than Perl hash. It's very fast methode for building applications. (preffered)
GUI* - GUI support is not fully implemented now.
We have database server (eg. MySQL) adn we have web server (eg. Apache). We want to build simple but powerfull web interface to database. So we can write simple CGI script. Medvedb contains a lot of very common functions for building web interface. So, we can write CGI script useing Medvedb.
Interface specification is written in Perl. We use structure hash, because it's very powerfull. When we have hash we call function from Medvedb. Medvedb parse our request and sends SQL queries to database server. When it recieves data from server, it starts to build interface from database reply and our specificatio reply. After all reply is send to user.
Perl hash is cool, but not for everyone. When you want to rewrite hash you need to change program. This is not very clean solution, so we develop XML specification. You can write simple XML file that contains same information as Perl hash and result is same. Using XML file you don't destroy application code and it's more human readable than Perl hash.
Medvedb is well designed so you can change XML configuration to any type of configuration without hurting kernel. You only add interface that reads configuration and than transforms all requests to Perl hash.
= = = = = = = = = = = = = = = = = = = XML interface ----> XML::Twig = = specifivation Parser = = = = = = = = = = = = = = = = = = = | V Perl Hash specification | V CGI ------- ----> Query --> input --> |Medvedb| transform. User |kernel | | <-- CGI <-- |-------| V optput |format.| <---- DBI:DBD <--> DB ^ ------- CSS
Database server, web server.
When XML is well formated you need only one command to build interface.
xml_file_name
is name of file where XML descrition is stored.
Several application may be stored in one XML file, to invoke
appropritiate application you need to specify allplicatio_name
.
No more commands are required to build interface.
Weaker from of cast_spell
, it requires XML file where only one
application is specified.
No more commands are required to build interface.
config(cfg_hash)
For advanced configuring you need this function.
dbconnect()
Connects to database server.
dbdisconnect()
Close connection to database.
htmlheader()
Returns HTML header and begin of HTML page.
htmlend()
Returns end of HTML page.
bar(%hash)
Build bar containing name of keys and hyper link to values of hash
htmlbar(%hash)
Build bar containing referrences to subaplications (eg. show, full)
print_view(%hash)
Starts main proces of Medvedb. Keys of hash are names of subapplications. Values are reference to hash specification of subaplications. It builds the view using appropritiate specification.
web: http://medvedb.sourceforge.net
Juraj Michalek
perl, CGI, XML::Twig