bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

DBI::Oracle is not supported correctly #36

Closed slatibart closed 11 years ago

slatibart commented 11 years ago

For example you can not set the sid string for the dbi connection.

$dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $passwd);

And I'm not sure if that is related to this plugin. I am setting ORACLE_HOME in the dancer script, so that DBI finds out about the tnsnames.ora and I don't need to set host and so on but somehow this ENV variable doesn't get used by DBI::Oracle. It is working for other non dancer scripts with perl.

regards

Andreas

bigpresh commented 11 years ago

Looks like allowing the sid string (I don't know what that is, offhand) should be easy enough - it'll be this bit of code which assembles the DSN which would need tweaking:

        for (qw(database dbname host port)) {
            if (exists $settings->{$_}) {
                push @extra_args, $_ . "=" . $settings->{$_};
            }
        }
        $dsn .= ':' . join(';', @extra_args) if @extra_args;

In the meantime, though, you can supply a pre-crafted DSN instead which should work?

slatibart commented 11 years ago

Hi David,

sid is a kind of db_identifiert alias for the hostname and port

http://search.cpan.org/~pythian/DBD-Oracle-1.52/lib/DBD/Oracle.pm

$dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $passwd);

Probably a keyword like ORACLE_SID would work. I've got my connection running, with some workaround.

If that is an easy fix would love to see it done.

regards

Andreas

On 10/29/12 21:19, David Precious wrote:

Looks like allowing the |sid| string (I don't know what that is, offhand) should be easy enough - it'll be this bit of code which assembles the DSN which would need tweaking:

     for  (qw(database dbname host port))  {
         if  (exists  $settings->{$_})  {
             push  @extra_args,  $_  .  "="  .  $settings->{$_};
         }
     }
     $dsn  .=  ':'  .  join(';',  @extra_args)  if  @extra_args;

In the meantime, though, you can supply a pre-crafted DSN instead which should work?

— Reply to this email directly or view it on GitHub https://github.com/bigpresh/Dancer-Plugin-Database/issues/36#issuecomment-9885869.

tyupshaw commented 11 years ago

Hi Andreas,

I've got my connection running, with some workaround. Would you be so kind as to share your workaround since an update to Dancer-Plugin-Database has not been released yet?

Advance Thanks, Tiffany

bigpresh commented 11 years ago

Thanks for the reminder of this issue - I'll try to get a new release out shortly with the appropriate fix for you @tyupshaw

bigpresh commented 11 years ago

@tyupshaw by the way, the workaround I suggested of using a pre-crafted DSN (via the dsn param) instead of the database, host etc params should work for you in the meantime.

bigpresh commented 11 years ago

Right, done in b3f4cbfb3539db4f7b54e48696cd0bfa569322de and version 2.04 released to CPAN just now.

You can now use sid as a parameter in your config, e.g.:

plugins:
    Database:
        driver: Oracle
        host: localhost
        sid: ABC12

and it will get used in the DSN for you.