我从数据库世界开始。我正在尝试使用Perl脚本从SQLite3中的数据库中获取一些数据。我想要做的第一步是删除现有的表,然后使用新数据创建另一个表。我的代码是:
#!/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();
但是我收到以下错误:
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.
在sqlite3命令行中它可以正常工作。有什么想法吗?
嗯,提前谢谢。
答案 0 :(得分:0)
删除第二个;
Bit_score INT););