[dancer-users] Better Solution ?

Stefan Hornburg (Racke) racke at linuxia.de
Thu Apr 11 13:27:52 BST 2013


On 04/11/2013 02:14 PM, Hugues Max wrote:
> Hello
> I need to write a Dancer Application where I need to connect to Microsoft Access 97/2003 Database... :'(
> 
> I use DBI::Proxy
> 
> my $dsn      = "DBI:Proxy:hostname=$IP;port=$PORT;dsn=DBI:ODBC:$ODBC";
> my $dbh = DBI->connect($dsn, "", "") || die "Erreur de connexion à la base";
> $dbh->{AutoCommit} = 1;
> $dbh->{RaiseError} = 1;
> 
> it's not fast but it's works.
> 
> I tried to use  Dancer::Plugin::Database but Microsoft SQL is not compatible ( Limit doesn't exist, this is TOP etc.. )

You could still use Dancer::Plugin::Database for setting up and maintaining the database connection.

> 
> my %ClientParc ;
> $sql =q/SELECT Spécifique, Quantité, PrixMaintenance FROM ClientParc WHERE NumContrat=? AND CodeClient=?/;
> $stha = $dbha->prepare($sql);
> $stha->execute($NumContrat, $CodeClient );
>  while (my ($Specifique, $Quantite, $PrixMaintenance) = $stha->fetchrow_array()) {
> $ClientParc{$Specifique} = {  Specifique      => $Specifique, Quantite        => $Quantite,     PrixMaintenance => $PrixMaintenance        }
> }
> 
>  I create a hash %ClientParc and I send it to TTK
> and I do
> 
> return template '/echeancier' => {
>     ClientParc => \%ClientParc
> }
> in my view
> 
> [% FOREACH s IN ClientParc.values -%]
> 
>         [%- IF loop.first %]
>                 <div class="span5">             [% s.Quantite %] [% s.Specifique %] </div>
>         [% ELSE %]
>                 <div class="span5 offset5">     [% s.Quantite %] [% s.Specifique %] </div>
>         [% END %]
> [% END %]
> 
> And it's works but
> 
> I got 2 questions
> 1 ) are they a better solution ?

Obviously make a better choice on your database backend :-).

> 2) for each page , I need to connect to MS Access proxy and this is slow ( 2 ou 3 sec for connection, but after queries are  enough fast ), 
> are they a solution to maintain a DB connection  ?

How and where do you connect?

Regards
	Racke


-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team



More information about the dancer-users mailing list