我是Databse的新手。我在我的系統上安裝了SQLite和嘗試運行Perl程序插入到DATABSE使用DBD :: SQLite模塊嘗試在PERL中插入數據庫時出現問題
SQLite的命令來創建數據庫和表
在命令提示符下,我反覆對於SQLite目錄,並給出命令,
sqlite3 one.db;
create table table1 (a int, b string);
它創建了一個數據庫和表
我執行的跟着Perl程序
use strict;
use warnings;
use DBI;
use DBD::SQLite;
my $dbh = DBI->connect("dbi:SQLite:dbname=one.db","","") or die "cannot
connect";
my $sth = $dbh->prepare("INSERT INTO 'table1'
(Income, LAST_NAME)
values
('1000', 'poul')");
$sth->execute() or die $DBI::errstr;
$sth->finish();
$dbh->commit or die $DBI::errstr;
我有以下錯誤
DBD::SQLite::st execute failed: no such table: table1 at DBI.txt line 14.
no such table: table1 at DBI.txt line 14.
從IKEGAMI
得到的意見後,我改變了DBI->connect
作爲
my $dbh = DBI->connect
("dbi:SQLite:dbname=C:/Users/nitkumar/Downloads/sqllite/one.db","","
") or die "cannot connect";
,我開始收到錯誤消息
DBI connect('dbname=C:/Users/nitkumar/Downloads/sqllite/one.db','',...) failed:
database disk image is malformed at DBI.txt line 8
cannot connect at DBI.txt line 8.
越來越意見後我通過使用
use DBD::SQLite;
warn $DBD::SQLite::VERSION;
warn $DBD::SQLite::sqlite_version;
我得到了output
作爲
1.37 at version.txt line 2.
3.7.12.1 at version.txt line 3.
我使用sqlite3
。我猜這個版本沒有問題
如果這是原因,那麼它會打印錯誤消息說「無法連接」。但它沒有給出任何這樣的錯誤。糾正我,如果我錯了 – Nitesh
好的。如何給數據庫的路徑??。假設我在'c:// sqlite'文件夾中創建了數據庫 – Nitesh
Nit:'b text'比'b string'更有意義 – ikegami