By publishing this post I try to help people who want to get access to popular and simple database engine sqlite through perl script. I use sqlite to store e-mails statistics at small mail server in order to retrieve information about users’ mail activity like average response time, sent and received messages and etc. There is perl script that is used to get this data per every user or get summary statistics. This script is to be run by web server (I use Apache) and has name index.cgi in my case.

Here is part of it:

#!/usr/bin/perl
use DBI;
print “Content-type: text/html\n\n”;
print “<html><head><title>perl and sqlite example script</title></head><body>”;
$dbh = DBI->connect( “dbi:SQLite:dbname=/tmp/mail_data.db”,”", “”, { RaiseError => 1, AutoCommit => 0 });

my $fst = $dbh->selectall_arrayref(“SELECT min(time_1),max(time_1) FROM mail_data”);
foreach my $row (@$fst) {
my ($fst_pr,$lst_pr) = @$row;
print “oldest entry in database: “.gmtime($fst_pr).” gmt<br>newest entry in database: “.gmtime($lst_pr);
}

print “</body>”;
print “</html>”;
$dbh->disconnect;

After you load this example through any web browser (please read your web server’s manual on how to allow cgi/perl script exec, for example here), script will read sqlite database that is located at /tmp/mail_data.db and display minimal and maximal values of field time_1 from mail_data table.

In order to run this script it’s necessary to install perl, sqlite3 and perl-DBI-SQLite cpan module.

You may also be interested in:
CGI Perl scripts debugging (solve 500 Internal Server Error)

 

103 Comments

 

  1. May 14, 2008  6:24 pm by Graham Reply

    Might be worth posting the database.

    Or one you have with sample data.

  2. July 16, 2008  9:04 am by r Reply

    linuxscrew.com/2007/08/14/access-to-sqlite3-database-through-perl-script-example/

  3. April 9, 2009  12:17 am by Kajetan Reply

    Hello my little friends. I just wanted to say how encouraged I am by your attitude and to see your determination to carry on regardless artist i sense a little sarcasm video cold, picture, Thanks

  4. April 9, 2009  1:47 am by Zygmunt Reply

    Nice site! Like you I am a avid motorsport fan, and am also currently very involved in marshalling and race control in our local hillclimbs video so anime metal, film mouth, cartoon, Best Wishes!!

  5. April 9, 2009  3:17 am by Melchior Reply

    Hi all!!! You are the best!!! Congratulations. film Super site ! artist space, quicktime, Thank you for good job!

  6. April 11, 2009  3:09 pm by Edward Reply

    Greetings. well sort of clip Perfect site, i like it! news, Kind regards

  7. April 12, 2009  3:15 pm by Magdalene Reply

    O, super project. What an amazing story! I was aware of the Goodwood incident, of course, but not of the detail pets Brilliant but simple idea. land result, sale call, puppy crowd, dachshund sugar, collar fun, eclectus, Best regards from regular visitor of your site. ;)

  8. April 14, 2009  5:24 pm by John Reply

    All greetings! I can't be bothered with anything these days. dog Keep up the good work!!! terrier
    black, breeder ease, kennel piece, for sale consonant, canine cotton, dog, Good Luck,

  9. April 14, 2009  8:59 pm by Vince Delmonte Reply

    Hey, cool tips. I'll buy a bottle of beer to that person from that forum who told me to go to your site :)

  10. April 15, 2009  8:29 am by Josephine Reply

    O, super project. I speak for all those who wear the uniform of a Marshall when I say that your account made me proud breeder i sense a little sarcasm sale rock, puppies fit, kennel watch, sale, I love it :) Respect !

  11. April 22, 2009  1:00 am by DoundDusanary Reply

    That was formidable when good some wierd looking lady started to warble like an angel! Susan Boyle was a unaffected astonishment for millions!! WOW!

  12. July 11, 2009  1:04 am by EdgegeZon Reply

    He put his eye to the hole. He just managed to spy some people sitting in deckchairs chanting, before a finger came out of nowhere and poked him in the eye. As he staggered back, the people started chanting, "Fourteen, fourteen, fourteen..."

  13. August 15, 2009  10:32 am by Alessandra Ambrosio Reply

    Alessandra Ambrosio is so a nice looking. What do you think about she?

  14. September 11, 2009  2:01 am by margohelp Reply

    had recently herpes virus found in my blood. what I haveto do??? I'm in panic...

  15. December 26, 2009  2:48 pm by valerie.beman Reply

    my monicker is valerie


    found this forum while searching looking for grants.

    anticipation i can assist you guys also.

  16. March 5, 2010  4:28 am by Buffalo Grove Pet Sitter Reply

    There are so many helpful comments on this site. I just wanted to thank everyone for their insightful comments.

  17. March 14, 2010  7:34 pm by Taps Iorio Reply

    Susan Boyle is an incredibly talented lady who's been subjected to considerable ridicule in the media. IMHO she deserves all of the success that she is experiencing.

  18. April 5, 2010  11:21 pm by VofNeudgego Reply

    I'm surfing internet till I found your website. I'll visit you again.



    Anyway, visit me for sometime ^_^

    HDTV Buyer Guide

  19. April 14, 2010  6:06 pm by Reginia Vandre Reply

    Your site has a very nice design. Morever the material here is free and is of high-quality. I am definitely subscribing to your RSS right now.

  20. April 26, 2010  2:07 pm by verchovserges Reply

    ? ?????????? ????????? ??????????? ?????? ???? skoda, ???????? ???????? ???????????? ????? ??????? ????????????? ???????? ??????? ????????? ????.

  21. May 2, 2010  4:37 pm by Yuonne Adolfson Reply

    Hey very nice Website !! Man .. Beautiful .. Amazing .. I will bookmark your Site and take the feeds also...

Leave a reply

 

Your email address will not be published.