I'm starting in the world of databases. I'm trying to make a Perl script to get some data from a database in SQLite3. The first step I want to do is remove a existing table and then create another with new data. My code is:
#!/usr/bin/perl
use DBI;
use strict;
my $driver = "SQLite";
my $database = "/media/My\ Passport/Sources/M5nr_db";
my $dsn = "DBI:$driver:dbname=$database";
my $userid = "";
my $password = "";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
or die $DBI::errstr;
print "Opened database successfully\n";
my $stmt = qq(DROP TABLE IF EXISTS matching_prot );
my $rv = $dbh->do($stmt);
my $stmt = qq(CREATE TABLE matching_prot
(Seq_ID TEXT,
M5 TEXT,
Identity REAL
Evalue REAL
Bit_score INT););
my $rv = $dbh->do($stmt);
$dbh->disconnect();
But I get the following error:
Opened database successfully
DBD::SQLite::db do failed: near "EXISTS": syntax error(1) at dbdimp.c line 269 at use_database.pl line 16.
DBD::SQLite::db do failed: near "EXISTS": syntax error(1) at dbdimp.c line 269 at use_database.pl line 16.
In the sqlite3 command-line it works fine. Any ideas?
Well, thanks in advance.