Hi all,

 

I want to using SEC integrated with a database follow the page
http://simple-evcorr.sourceforge.net/SEC-tutorial/article-part2.html#DATABAS
EINTEGRATION 

Start the script 

S8.2.01.pl :

#!/usr/bin/perl

# Example S8.2.01.pl  - Script to read data out of a named pipe

$| = 1;

use strict;

use DBI();

my $filename;

my $inputline;

my $linenumber;

# Open FIFO first.  FIFO must already exist.

$filename = "./SEC_fifo";

open(FIFO, "+< $filename") or die "FIFO error on $filename $!";

# Connect to MySQL. Database 'sedb' must already exist.

my $dbh = DBI->connect("DBI:mysql:database=sedb;host=localhost",

            "root", "dummy",

            {'RaiseError' => 1});

# Drop table 'foo'. This may fail, if 'foo' doesn't exist.

# Thus we put an eval around it.

eval { $dbh->do("DROP TABLE foo") };

print "Dropping table foo failed: $@\n" if $@;

# Create a new table 'foo'. This must not fail, thus we don't

# use eval.

$dbh->do("CREATE TABLE foo (id INTEGER, textline VARCHAR(80))");

print "Reading from FIFO...\n";

while (<FIFO>)

{

  $inputline = $_;

  # Quit read loop when requested.

  last if($inputline =~ /quit/i);

  chop $inputline;

  $linenumber++;

  print "Got: [$inputline], ";

  # Insert data into table 'foo', using placeholders

  $dbh->do("INSERT INTO foo VALUES (?, ?)",

                undef,

                $linenumber,

                $inputline);

  print "inserted it.\n";

}

# Now retrieve data from the table.

my $sth = $dbh->prepare("SELECT * FROM foo");

$sth->execute();

while (my $ref = $sth->fetchrow_hashref()) {

  print "Found a row: id = $ref->{'id'}, line = $ref->{'textline'}\n";

}

# Drop table 'foo'. At this point, table 'foo' exists, so

# we won't use an eval.

$dbh->do("DROP TABLE foo");

$sth->finish();

# Disconnect from the database.

$dbh->disconnect();

exit;

 

 

and I have SEC_fifo in the directory, next start up the reading script:

# perl S8.2.01.pl

Reading from FIFO...

 

 

Then In another window, enter the following:

$ echo blah blah blah >> SEC_fifo

 

 

But the script can't get anything and didn't show any error 

 

Can anyone give me some advice on what to do please?

 

Andrew 

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Simple-evcorr-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to