Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Working with DBI and DBD::SQLite2

by gmax (Abbot)
on Oct 29, 2004 at 20:31 UTC ( #403900=note: print w/replies, xml ) Need Help??

in reply to Working with DBI and DBD::SQLite2

You have a quoting problem. Use placeholders!

my $sta=$dbh->prepare("INSERT INTO ISP(Store,Date) VALUES(?, ?)"); my $stb=$dbh->prepare("INSERT INTO UnityPrimary(Store,Date) VALUES(? +, ?)"); my $stc=$dbh->prepare("INSERT INTO UnitySecondary(Store,Date) VALUES +(? , ?)"); $sta->execute($store,$isp); $stb->execute($store,$pri); $stc->execute($store,$sec);

BTW, some error checking would not be out of order either.

 _  _ _  _  
(_|| | |(_|><

Replies are listed 'Best First'.
Re^2: Working with DBI and DBD::SQLite2
by Taulmarill (Deacon) on Oct 29, 2004 at 20:41 UTC
    as supplement: this is definitely the problem, use always placeholders! some values have to be quoted so the db knows where the value ends. also you you can speed up the inserts by reuseing your statements and performing them all in one transaction.
    $dbh->do('BEGIN TRANSACTION'); my $sta=$dbh->prepare("INSERT INTO ISP(Store,Date) VALUES(?, ?)"); my $stb=$dbh->prepare("INSERT INTO UnityPrimary(Store,Date) VALUES(?, +?)"); my $stc=$dbh->prepare("INSERT INTO UnitySecondary(Store,Date) VALUES(? + , ?)"); while (<CSV>){ chomp; my($store,$isp,$pri,$sec)=split /,/; $sta->execute($store,$isp); $stb->execute($store,$pri); $stc->execute($store,$sec); } $dbh->('END TRANSACTION');
    oh yes, and definements like INTEGER or CHAR[9] mean nothing to SQLite2. the only column define which is usefull is PRIMARY KEY INTEGER for self generating unique keys.

    update: just for your information, DBD::SQLite $VERSION >= 1 is actualy SQLite 3, DBD::SQLite2 was made to update the SQLite 2 path. just in case you want to benefit from the new features in v3 but didn't know how weird the modules are named.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://403900]
[haukex]: Corion: I once wrote an automated thingy for that here
[haukex]: here's the code that uses it
[Corion]: haukex: Hmm - maybe I can reuse that. I see that it uses Pod::Parser, which I think was one of the more fragile parsers. But if I'm statically (re)generating the tests instead of doing that "live" on the client/tester machines, that's a much smaller...
[Corion]: ... problem space than trying to cater to all versions of Pod::Parser(s)
[haukex]: I think you're right, I think Pod::Simple is the preferred parser now
[haukex]: But I was just using it as an author test anyway
[Corion]: haukex: Aaah - I thought you were still running these tests on every machine, but you only run these as author or Devel::Cover tests
[Corion]: haukex: Yeah, I think back then I used Test::Inline, which used a pod parser that was going through some changes and I didn't want to cater for all the various versions and thus stopped testing the Pod completely
[choroba]: I usually do this with presentations

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-02-27 12:22 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.