Re: RFI: Database URIs

Jens Rehsack <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
Am 25.11.2013 um 18:00 schrieb David E. Wheeler <[email protected]>:

> On Nov 25, 2013, at 3:50 AM, Jens Rehsack <[email protected]> wrote:
> 
>>   DBI->connect($dsn, $user, $passwd, \%attr)
>> 
>> 4th argument is wasted in your current proposal.
> 
> Er, well, I failed to provide a complete set of examples. Here’s one from the PostgreSQL docs:
> 
>  postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
> 
> All the attributes are provided by the GET query string.

Let’s go - shoot:

    # specify most possible flags via driver flags
    $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
        f_schema         => undef,
        f_dir            => "data",
        f_dir_search     => [],
        f_ext            => ".csv/r",
        f_lock           => 2,
        f_encoding       => "utf8",

        csv_eol          => "\r\n",
        csv_sep_char     => ",",
        csv_quote_char   => '"',
        csv_escape_char  => '"',
        csv_class        => "Text::CSV_XS",
        csv_null         => 1,
        csv_tables       => {
            info => { f_file => "info.csv" }
            },

        RaiseError       => 1,
        PrintError       => 1,
        FetchHashKeyName => "NAME_lc",
        }) or die $DBI::errstr;

And keep in mind, csv_tables can be more complex and there’re other
attributes like it eg. in DBD::AnyData.

Cheers
-- 
Jens Rehsack
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.