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

I am using DBD::SQLite, my problem is where do i put the database file, in which location?


I had been geting this message-

[Mon Apr 26 16:02:35 2004] myp2p.cgi: DBD::SQLite::st execute failed: +no such table: employee at C:/Perl/lib/my_lib.pm line 385.

Replies are listed 'Best First'.
Re: Table in SQLite
by neeraj (Scribe) on Jul 16, 2004 at 08:11 UTC
    You can put your database file anywhere provided the script has access to that file. Like i can put file add.db in /home/neeraj. To access the file , i use the followinf code :-
    my $str= "DBI:SQLite:/home/neeraj/add.db"; $dbh= DBI->connect( $str ) || die "Can't connect to database: $DBI::e +rrstr!" ;

      You can put your database file anywhere provided the script has access to that file.

      It also needs write permissions on the directory. That's why I usually create a directory for SQLite databases.

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      before this I was using MySQL, the database was kept in c:/MySQL/Data/ but in my script it like this

      $dbh= DBI->connect("dbi:$dbtype:$dbname_ss;$dbip", "$dbuser", "$dbpass");


      my $dbname_ss = "nehnu";
      my $dbname_base_app = "hrms_base_ranhil";
      my $dbip = "localhost";
      my $dbuser = "root";
      my $dbpass = "";
      my $dbtype = "mysql";

      So when I change to DBD::SQLite I change it but, it didn't work. I don't know how the last time I use MySQL it refer to c:/MySQL/Data/databasename but it work...

        The difference is that MySQL runs as a server and accesses a directory to store its database, and SQLite is library that reads a single file.

        DBD::mysql connects to the server (localhost), chooses a database (nehnu), which is mapped to a disk location (c:/MySQL/Data/database), and logs in with a user (root). The DSN contains all that info:

        DBI->connect("dbi:mysql:nehnu;localhost", "root", "");

        DBD::SQLite opens the database file. The DSN just needs the filename:

        DBI->connect("dbi:SQLite:/SQLite/Data/database.sqlt");
Re: Table in SQLite
by Anonymous Monk on Jul 17, 2004 at 03:44 UTC
    The database you're opening has no table named employee. This is extremely clear from the error message. You have to create a table employee if you're going to be querying/updating it.
A reply falls below the community's threshold of quality. You may see it by logging in.