Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I wanted a simple database to track the dates that our servers were last rebooted, so I decided to use the DBD::SQLite2 module. Well, I am having a problem at the moment, and need some advice.This is running on a Windows NT 4 workstation (ActiveState Perl 5.8.4 Build 810)
The code:
#!perl -w use strict; use DBI; my $D=DBI->connect("DBI:SQLite2:dbname=Store.db","",""); $D->do("CREATE TABLE ISP(Store INTEGER,Date CHAR[9])"); $D->do("CREATE TABLE UnityPrimary(Store INTEGER,Date CHAR[9])"); $D->do("CREATE TABLE UnitySecondary(Store INTEGER,Date CHAR[9])"); open(CSV,"reboots.csv")||die"Can't open: $!\n"; while(<CSV>){ chomp; my($store,$isp,$pri,$sec)=split /,/; my $sta=$dbh->prepare("INSERT INTO ISP(Store,Date) VALUES($store,$is +p)"); my $stb=$dbh->prepare("INSERT INTO UnityPrimary(Store,Date) VALUES($ +store,$pri)"); my $stc=$dbh->prepare("INSERT INTO UnitySecondary(Store,Date) VALUES +($store,$sec)"); $sta->execute; $stb->execute; $stc->execute; } close CSV; my $sth=$dbh->prepare("SELECT * FROM UnityPrimary WHERE Store=1"); $s->execute; while(my@row=$s->fetchrow_array){ print "@row\n"; } $D->disconnect;
The data file:
1,18-Oct-04,29-Oct-04,29-Oct-04 2,18-Oct-04,26-Oct-04,26-Oct-04 3,21-Oct-04,26-Oct-04,11-Aug-04 4,20-Oct-04,11-Jun-04,27-Oct-04 5,18-Oct-04,3-Sep-04,24-May-04 6,17-Oct-04,15-Oct-04,15-Oct-04

The error messages:
DBD::SQLite2: :st execute failed: no such column: Oct(1) at dbdimp.c l +ine 412 at C:\WINNT\Profiles\toms\Desktop\createdb.pl line 26, <CSV> +line 1. DBD::SQLite2: :st execute failed: no such column: Oct(1) at dbdimp.c l +ine 412 at C:\WINNT\Profiles\toms\Desktop\createdb.pl line 27, <CSV> +line 1. DBD::SQLite2: :st execute failed: no such column: Oct(1) at dbdimp.c l +ine 412 at C:\WINNT\Profiles\toms\Desktop\createdb.pl line 28, <CSV> +line 1.
The above three error messages repeat themselves for each line in the .csv file. What exactly is causing this?

TStanley
--------
The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke

In reply to Working with DBI and DBD::SQLite2 by TStanley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (8)
    As of 2014-11-27 16:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (186 votes), past polls