change send data to sqlite test db and made it functional
This commit is contained in:
parent
f80ac5c8b2
commit
69c39d7c5c
1 changed files with 6 additions and 5 deletions
|
@ -4,18 +4,18 @@ use Mojolicious::Lite;
|
||||||
|
|
||||||
# connect to database
|
# connect to database
|
||||||
use DBI;
|
use DBI;
|
||||||
my $dbh = DBI->connect("dbi:Pg:dbname=$foodloop","","") or die "Could not connect";
|
my $dbh = DBI->connect("dbi:SQLite:dbname=foodloop.db") or die "Could not connect";
|
||||||
|
|
||||||
# shortcut for use in template
|
# shortcut for use in template
|
||||||
helper db => sub { $dbh };
|
helper db => sub { $dbh };
|
||||||
|
|
||||||
# setup base route
|
# setup base route
|
||||||
any '/' => 'index';
|
#any '/' => 'index';
|
||||||
|
|
||||||
my $insert;
|
my $insert;
|
||||||
while (1) {
|
while (1) {
|
||||||
# create insert statement
|
# create insert statement
|
||||||
$insert = eval { $dbh->prepare('INSERT INTO foodloop (user, company, currency) VALUES (?,?,?)') };
|
$insert = eval { $dbh->prepare('INSERT INTO foodloop (user, company, currency, filename) VALUES (?,?,?,?)') };
|
||||||
# break out of loop if statement prepared
|
# break out of loop if statement prepared
|
||||||
last if $insert;
|
last if $insert;
|
||||||
|
|
||||||
|
@ -29,8 +29,9 @@ post '/' => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $user = $self->param('user');
|
my $user = $self->param('user');
|
||||||
my $company = $self->param('company');
|
my $company = $self->param('company');
|
||||||
my $company = $self->param('currency');
|
my $currency = $self->param('currency');
|
||||||
$insert->execute($user, $company, $currency);
|
my $file = $self->req->upload('file');
|
||||||
|
$insert->execute($user, $company, $currency, $file->filename);
|
||||||
$self->render(text => 'It did not kaboom!');
|
$self->render(text => 'It did not kaboom!');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue