Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
Fatherhood.Org

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 56 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  

HOWTO Home

Current HOWTO: A mSQL and perl Web Server Mini HOWTO


A mSQL and perl Web Server Mini HOWTO: Running an Example Database Next Previous Contents

4. Running an Example Database

After completing the system installation we can now finally run a model application. Depending on the version of msql installed and the perl database interface used, we have to modify the sample programs in a few points.

First however, the file index.html residing in /home/httpd/html/ must be modified to allow calling a sample database application. We can place our database (which we call database.cgi or inventur.cgi here despite its archive name perl.lst.ck) in /home/httpd/html/test/.

We add one line (of course, depending on your installation choices) similar to the following to index.html:


<LI>Test the <A href="/modules.php?name=Howto&pagename=WWW-mSQL-HOWTO/test/database.cgi">Database, DBI:DBD-mSQL style!</A>
<LI>Test the <A href="/modules.php?name=Howto&pagename=WWW-mSQL-HOWTO/test/inventur.cgi">Database, MsqlPerl style!</A>

Usually you should only pick one of these two choices but if you have both types of database interface installed you can leave both lines here as they are. You can then compare performance, etc.

4.1 Adapting the sample script for MsqlPerl

Our sample script has to be told to use the MsqlPerl interface. The modification takes place in several locations. First, near the beginning of the file, we change the use clause:


#
# use DBI;            # Generisches Datenbank-Interface
use Msql;

Then, near line 27, the MsqlPerl syntax does not require the mentioning of a specific driver:


# $dbh = DBI->connect($host, $database, '', $driver) ||
$dbh = Msql->connect($host, $database) ||

Then, from line 33 onward throughout the whole script, we have to change all instances of do against query:


# $dbh->do("SELECT * FROM hw") || db_init($dbh);
$dbh->query("SELECT * FROM hw") || db_init($dbh);

Finally, in MsqlPerl speak, line 207 can be commented out:


# $sth->execute || msg("SQL Error:", $sth->errstr);

In addition, it may become necessary to swap all errstr calls like the one in the preceding code fragment against errmsg. This is also version dependent.

After these modifications, the script should run smoothly.

4.2 Adapting the sample script for msql-2

The SQL syntax was redefined during the development of mslq-2. The original script will fail to execute the table initialization statements in lines 45 -- 58. The primary key modifier is no longer supported by msql-2, and should simply be skipped:


    $dbh->do(<<EOT) || die $dbh->errstr; # Neue Personen-Tabelle
        create table person (
# We do not need the 'primary key' modifier anymore in msql-2!
#           pn        int primary key,   # Personalnummer
            pn        int,               # Personalnummer
            name      char(80),          # Nachname, Vorname
            raum      int                # Raumnummer
        )
EOT
    $dbh->do(<<EOT) || die $dbh->errstr; # Neue Hardware-Tabelle
        create table hw (
# We do not need the 'primary key' modifier anymore in msql-2!
#           asset int primary key,       # Inventurnummer
            asset int,                   # Inventurnummer
            name   char(80),             # Bezeichnung
            person int                   # Besitzer
        )
EOT

Unfortunately, this specific script will then accept new entries with identical personnel numbers; the msql-1 modifier primary key intends to prevent exactly this behaviour. The msql-2 documentation shows how to use the CREATE INDEX clause to create unique entries.


Next Previous Contents

The Linux Tutorial completely respects the rights of authors and artists to decide for themselves if and how their works can be used, independent of any existing licenses. This means if you are the author of any document presented on this site and do no wish it to be displayed as it is on this site or do not wish it to be displayed at all, please contact us and we will do our very best to accommodate you. If we are unable to accommodate you, we will, at your request, remove your document as quickly as possible.

If you are the author of any document presented on this site and would like a share of the advertising revenue, please contact us using the standard Feedback Form.


  
Help us cut cost by not downloading the whole site!
Use of automated download sofware ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and therefore is expressedly prohibited. For more details on this, take a look here

Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
You can choose larger fonts by selecting a different themes.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.41 Seconds