Creating Table in database from Perl using SQLite3 -
i'm having trouble creating table in database created perl using dbi sqlite3. using code have below, want table contain port-probes, 1 line each source ip , port. don't know if im doing properly, code below not work reason, appreciated. code have follows.
#!/usr/bin/perl use strict; use dbi; $dbh = dbi->connect( "dbi:sqlite:dbname=test.db", "", "", { raiseerror => 1} ) or die $dbi::errstr; $dbh->do(create table probes ( source char(15) not null, port char(5) not null, primary key (source,port)) ); $dbh->disconnect();
you forgot quote argument $dbh->do
. there many ways this.
$dbh->do( "create table probes ( ..." ); $dbh->do( 'create table probes ( ...' ); $dbh->do( qq[ create table probes ( ... ] ); $dbh->do( <<"end_sql" ); create table probes ( ... end_sql
added: fix problem, need put quotes around stuff in $dbh->do
function call.
$dbh->do("create table probes ( source char(15) not null, port char(5) not null, primary key (source,port))");
Comments
Post a Comment