Access to sqlite3 database through perl (script example)

Welcome to Linux Screw! If you're new here, you may want to subscribe our RSS feed.

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)

 
 
» You might also be interested in the following articles:
CGI Perl scripts debugging (solve 500 Internal Server Error)
Dump ipcad output into sqlite3
Tiny perl script for UDP flooding
Tiny bash scripts: check Internet connection availability
Web server oneliner with bash



» Want to stay up to date? Subscribe to our E-MAIL or RSS feed!

38 Responses to “Access to sqlite3 database through perl (script example)”


  1. 1 Graham

    Might be worth posting the database.

    Or one you have with sample data.

  2. 2 r

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

  3. 3 Kajetan

    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. 4 Zygmunt

    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. 5 Melchior

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

  6. 6 Edward

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

  7. 7 Magdalene

    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. 8 John

    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. 9 Vince Delmonte

    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. 10 Josephine

    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. 11 DoundDusanary

    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. 12 hnEydo

    The best scenes whith Alessandra Ambrosio (hot and sexy)!
    click here Alessandra Ambrosio nude gallary sextape or just follow the link http://digg.com/celebrity/Alessandra_Ambrosio_nude_pictures_naked_video_sextape_3
    You MUST SEE it, this girl really beautifull!!!

  13. 13 piniko

    Hey, you’ll love it. TOTALLY SHOCKING original video whith Tara Reid >>
    click here Tara Reid nude gallery sextape or just follow the link http://digg.com/celebrity/Tara_Reid_nude_pictures_naked_video_sextape
    You MUST SEE it, this chik really beautifull!!!

  14. 14 EdgegeZon

    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…”

  15. 15 Dupttigrarp

    These teens are so tired they don’t even wake up when the cum sprays on their face!
    Too tired? Too bad!b freematuregeriesexvideos Watch as horny boyfriends get the green light from their kinky teen babes amateurmaturemilf to have their way all night long! These girls sleep soundly as their boyfriends fondle, amateurfreemature finger and fuck their way to a messy climax that leaves their sleeping eyes plastered shut with cum!
    When these teens are too sleepy to fuck they have to listen to their pussy-craving boyfriends bitch and whine. adultvideosmature
    The solution? Let the boys be boys! These kinky teens let their boyfriends fondle, fuck and cum on their perfect teen bodies however they want so long as they don’t wake them up!

  16. 16 Alessandra Ambrosio Wallpapers

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

  17. 17 margohelp

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

  18. 18 valerie.beman

    my monicker is valerie

    found this forum while searching looking for grants.

    anticipation i can assist you guys also.

  19. 19 Ashlee

    Full sex tape video whith Ashlee Simpson
    click here Ashlee Simpson nude pictures naked video sextape or just follow the link http://beauty-bargains.bellasugar.com/7291126
    You MUST SEE it, this girl really HOT!!!

  20. 20 Buffalo Grove Pet Sitter

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

  21. 21 Taps Iorio

    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.

  22. 22 VofNeudgego

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

    Anyway, visit me for sometime ^_^
    HDTV Buyer Guide

  23. 23 Reginia Vandre

    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.

  24. 24 aspelutle

    ???????? «????????» ?????????? ????????????, ????????, ??????????, ?????, ?????????, ??????? ,
    ???????? ????? ?? ?. 8(495)923-88-40

  25. 25 CheapDeanoPills

    -



  26. 26 verchovserges

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

  27. 27 Steve Reyome

    Well, would you look at that..

  28. 28 jahdaikirchh

    Check out Elisha Cuthbert Nude Pictures Naked Video Sex Tape click here or just follow the link http://www.pollsb.com/polls/p2158702-elisha_cuthbert_s_sex_tape_demi_moore_s
    Fully uncensored

  29. 29 WatchMayweather6k

    Hey everyone I’m new here at http://www.linuxscrew.com. Site looks awesome.
    If you want to Watch Mayweather Fight for FREE
    This site Watch Mayweather Fight Online has it for FREE

    This thing is gonna be bad

  30. 30 Yuonne Adolfson

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

  31. 31 Edison Schouweiler

    hey,Awesome blogging dude! i am Fed up with using RSS feeds and do you use twitter?so i can follow you there:D.
    PS:Do you considered putting video to the blog to keep the visitors more interested?I think it works.Best wishes, Edison Schouweiler

  32. 32 forex-free-signals

    forex course free and FREE forex books
    Forex mercado abre posibilidades ilimitadas, permite la capital infinitamente, para recibir la libertad. Nuestros trading signal- es una de las formas a este. Detallada a smartfxsol.com

    forex trading system free and FREE forex books

  33. 33 Sports Updates

    I just wanted to thank you a great deal for this informative webpage. I have already bookmarked your webpage, when can free up some time I am going to have to do some deeper surfing of your site. Well back to searching for sporting event tickets

  34. 34 nflliga

    If you love watching NFL, then you perhaps also proclivity to wager on the gamble, and extraordinarily on your favorite teams?

  35. 35 Dreafefom
  36. 36 jeynkossteli

    ??????????? ????????? ?? ?????????? ??? ?????????? ??????? ???? ?????????, ????? ??? – ??????? ??????????, ??????????? ?????????? ? ???????? ???????????.

  37. 37 Pyncpoungunny

    Gday,

    How is everyone? I’m most recent here!

    Bye for now.

    Keely

  38. 38 DaSSuka

    i need to prove i have the original version of windows. it only lets me go to the internet “to buy the real windows” and after an hour it logs me out.

    ___________________
    Dentysta

Leave a Reply




Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
Linux HOWTOs, Tutorials & Projects with Adam Palmer | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››