Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

how to use DBD::SQLite

by Anonymous Monk
on Jul 15, 2004 at 13:33 UTC ( #374643=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want to change to DBD::SQLite, how to do that as currently i am using MySQL. What need to be change?
use DBI; use CGI::Carp "fatalsToBrowser"; # Output errors to browser use CGI qw(:standard); # Saves loads of work $CGI::POST_MAX=1024 * 150; # limit post data $CGI::DISABLE_UPLOADS = 1; # Disable uploads use ehr_config; ($dbname_ss, $dbname_ba, $dbip, $dbuser, $dbpass, $dbtype) = initDbase +; ($cgidir, $imgdir, $template_dir, $table_color, $writedir)= initDirBas +e; $dbh = DBI->connect("dbi:$dbtype:nehnu:$dbip", "$dbuser", "$d +bpass"); $dbh_base_app = DBI->connect("dbi:$dbtype:$dbname_ba:$dbip", "$dbuser" +, "$dbpass");

Replies are listed 'Best First'.
Re: how to use DBD::SQLite
by dragonchild (Archbishop) on Jul 15, 2004 at 13:49 UTC
    The main difference is that SQLite is a much lighter engine that MySQL. This means that your application will have to do many more things that MySQL usually did for you. I'm in the process of converting one of my apps from Oracle to MySQL and while there's not a lot of changes, there's a few. (Primarily things like NVL() -> IFNULL() and the like.)

    One thing we've considered is subclassing our database class. We have a class called ABCD::Database which provides business-level functions to the other classes. Sort of like canned queries. You could have an ABCD::Database::MySQL and an ABCD::Database::SQLite, which will seriously aid your migration.

    The actual Perl you use will probably change very little, if at all. The changes will be in the SQL you use. (Unless, of course, you were using formatting functions in your SQL, in which case you may have to provide that functionality yourself.)

    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

Re: how to use DBD::SQLite
by cchampion (Curate) on Jul 15, 2004 at 14:15 UTC

    In addition to looking at DBD::SQLite docs, as others have advised, you may want to consider a migration tool: MySQL 2 SQLite

Re: how to use DBD::SQLite
by gellyfish (Monsignor) on Jul 15, 2004 at 13:40 UTC

    Beyond changing the details you pass to DBI->connect() you may get away without changing anything - the details you will need are discussed clearly in the the DBD::SQLite documentation


Re: how to use DBD::SQLite
by knoebi (Friar) on Jul 15, 2004 at 13:42 UTC
    my $dbh = DBI->connect("dbi:SQLite:dbname=dbfile","","");
    from the DBD::SQLite Documentation.

    you also have to convert your tables and move your data to SQLite... ;-)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://374643]
Approved by gellyfish
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2023-12-11 16:55 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (41 votes). Check out past polls.