Adam
view release on metacpan or search on metacpan
ex/ai-bot.pl view on Meta::CPAN
package MemoryStore {
use Moose;
use DBI;
has db_file => ( is => 'ro', default => sub { $ENV{DB_FILE} || 'ai-bot.db' } );
has _dbh => ( is => 'ro', lazy => 1, builder => '_build_dbh' );
sub _build_dbh {
my ($self) = @_;
my $dbh = DBI->connect('dbi:SQLite:dbname=' . $self->db_file, '', '', {
RaiseError => 1, sqlite_unicode => 1,
});
$dbh->do('CREATE TABLE IF NOT EXISTS conversations (
id INTEGER PRIMARY KEY, nick TEXT, message TEXT, response TEXT,
channel TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)');
$dbh->do('CREATE TABLE IF NOT EXISTS notes (
id INTEGER PRIMARY KEY, nick TEXT, content TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)');
return $dbh;
( run in 0.467 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )