[lug] mysql-driven pages

Tkil tkil at scrye.com
Thu Nov 11 23:28:15 MST 1999

thanks to Tony for the talk on mysql tonight.

i thought people might like to see a working and complete (albiet
rather small) demonstration of how mysql can be used.  

earlier this year, i built a browser for my own "cd database", with a
perl CGI as the front end, and mysql as the back end.  the actual
browser is at:


all those links point to different views of the data.  this was mostly 
my exercise for teaching myself CGI and DBI programming in perl; at
the top and bottom of each page, you can see a link to the actual
source of the program:


there is also a directory with all my support files in it:


i'll warn you in advance that these files are not very well-
commented.  probably the most important file in there is
"read-workman", which goes through the workmandb-full file (of which
workmandb-excerpt is the first few hundred lines, so you don't have to
download the 700kB file ... hey, i should gzip that!).  

you can find the most relevant bits of "read-workman" by searching for 
"$dbh".  the DBI documentation starts out fairly gently; reading the
first page or two gives you a gentle introduction to it, although the
perl syntax might scare you off.  an HTML version of this can be found 


for the record, this stuff is working flawlessly on my box.  current
versions are:

| $ uname -a
| Linux slinky.scrye.com 2.2.13 #1 Sun Oct 31 18:40:39 MST 1999 i586 unknown
| $ perl -v
| This is perl, version 5.005_03 built for i386-linux
| ...
| $ perl -MCPAN -e shell
| cpan> i DBI
| Bundle          Bundle::DBI     (TIMB/DBI-1.13.tar.gz)
| Module          DBI             (TIMB/DBI-1.13.tar.gz)
| cpan> i DBD::mysql
| Bundle          Bundle::DBD::mysql (JWIED/Msql-Mysql-modules-1.2209.tar.gz)
| Module          DBD::mysql      (JWIED/Msql-Mysql-modules-1.2209.tar.gz)
| $ mysql -u tkil_ro Tkil_CDs
| mysql> status
| mysql  Ver 9.35 Distrib 3.22.26a, for pc-linux-gnu (i686)
| ...
| Server version		3.22.26a
| ...

as a parting shot, a very simple use of DBI in CGI to generate a web
page is a script i used to test my database.  the script itself can be 
viewed at:


while the cgi proper (which generates about 125kB of output, all in
one table, so it takes a while to download and possibly to render) is


if you want to avoid one big dump, use "browse-cds" instead.
(although, with the huge number of links on each page, they still
weigh in at 45kB or more each.  and yes, that interface is ugly.  i'll 
fix it, eventually.  or not.  it *is* a toy.)

hopefully this is helpful.  comments about my [lack of] musical taste
will be ignored with dignity.


p.s. i remember a particularly amusing message sent to the general
     mysql mailing list recently.  they asked:  "can mysql handle the
     load put on a server when a sight gets 'slashdotted'?"  this is
     funnier if you know that slashdot.org itself is run with apache
     using mod_perl to call a mysql backend.  heh.

More information about the LUG mailing list