Hello All,

 

Thanks for your suggestions. I have following code written to list all
available drivers along with respective data-sources. But, I get some
errors for Oracle driver, can anybody please suggest the solution?
Thanks

 

===============

#!/usr/local/bin/perl

 

use DBI;  # for database

 

### Probe DBI for the installed drivers

my @drivers = DBI->available_drivers();

 

die "No drivers found!\n" unless @drivers; # should never happen

 

### Iterate through the drivers and list the data sources for

### each one

foreach my $driver ( @drivers ) {

    print "Driver: $driver\n";

    my @dataSources = DBI->data_sources( $driver );

    foreach my $dataSource ( @dataSources ) {

        print "\tData Source is $dataSource\n";

    }

    print "\n";

}

===============

 

And I get the following output

 

C:\Perl\bin>dbi_drivers.pl

Driver: CSV

        Data Source is DBI:CSV:f_dir=.

 

Driver: DBM

        Data Source is DBI:DBM:f_dir=.

 

Driver: ExampleP

        Data Source is dbi:ExampleP:dir=.

 

Driver: File

        Data Source is DBI:File:f_dir=.

 

Driver: Gofer

 

Driver: ODBC

        Data Source is dbi:ODBC:MS Access Database

        Data Source is dbi:ODBC:Excel Files

        Data Source is dbi:ODBC:dBASE Files

        Data Source is dbi:ODBC:myodbc3-test

        Data Source is dbi:ODBC:Visio Database Samples

        Data Source is dbi:ODBC:friday

        Data Source is dbi:ODBC:sunday_new

        Data Source is dbi:ODBC:junk

        Data Source is dbi:ODBC:sunday_another_new

        Data Source is dbi:ODBC:sunday_another_another_new

        Data Source is dbi:ODBC:sunday_another_another_new_comp

        Data Source is dbi:ODBC:example

        Data Source is dbi:ODBC:junk1

        Data Source is dbi:ODBC:july

 

Driver: Oracle install_driver(Oracle) failed: Can't load
'C:/Perl/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle:
load_file:The specified module could not be found at
C:/Perl/lib/DynaLoader.pm line 226.

 at (eval 37) line 3

Compilation failed in require at (eval 37) line 3.

Perhaps a required shared library or dll isn't installed where expected

 at C:\Perl\bin\dbi_drivers.pl line 19

 

 

-----Original Message-----
From: Martin Evans [mailto:martin.ev...@easysoft.com] 
Sent: 29 June 2010 17:16
To: Ashish Mukherjee
Cc: Sharma, Sumit; dbi-users@perl.org
Subject: Re: How to use perl dbi to create a database

 

Ashish Mukherjee wrote:

> http://search.cpan.org/~timb/DBI-1.611/DBI.pm#data_sources

> 

> This is how you can check for existence of a database.

> 

> - Ashish

 

That won't help you with some DBDs e.g., with DBD::ODBC this returns a

list of data sources and not databases. In DBD::ODBC a data source does

not have to name a database. A data source is a means to connect to a

database engine and it may contain multiple databases. Usually there is

some meta table where you can select the list of databases and a method

of changing from one to another. As an example, when you create an ODBC

data source for MS SQL Server (via the GUI ODBC Administrator) you can

choose any name you like for the data source and you can pick the

database or leave it to the default database but there is no direct

relationship between the data source name and the database (unless you

use that convention yourself).

 

Martin

-- 

Martin J. Evans

Easysoft Limited

http://www.easysoft.com

 

 

> On Mon, Jun 28, 2010 at 2:21 PM, Sharma, Sumit
<sumit.sha...@aeroflex.com>wrote:

> 

>> Hello,

>> 

>> 

>> 

>> I am trying to use Perl to identify if a given database exists or not

>> and if it doesn't create the database and then connect to it.

>> 

>> 

>> 

>> Is there any way using Perl DBI to first identify whether a given

>> database exists or not if it doesn't create the database?

>> 

>> 

>> 

>> Sumit

>> 

>> 

>> Notice: This e-mail is intended solely for use of the individual or
entity

>> to which it is

>> addressed and may contain information that is proprietary,
privileged,

>> company confidential

>> and/or exempt from disclosure under applicable law. If the reader is
not

>> the intended

>> recipient or agent responsible for delivering the message to the
intended

>> recipient, you are

>> hereby notified that any dissemination, distribution or copying of
this

>> communication is

>> strictly prohibited. If this communication has been transmitted from
a U.S.

>> location it may

>> also contain data subject to the International Traffic in Arms
Regulations

>> or U.S. Export

>> Administration Regulations and cannot be disseminated, distributed or

>> copied to foreign

>> nationals, residing in the U.S. or abroad, without the prior approval
of

>> the U.S. Department

>> of State or appropriate export licensing authority. If you have
received

>> this communication

>> in error, please notify the sender by reply e-mail or collect
telephone

>> call and delete or

>> destroy all copies of this e-mail message, any physical copies made
of this

>> e-mail message

>> and/or any file attachment(s).

>> 

>> 

> 


Notice: This e-mail is intended solely for use of the individual or entity to 
which it is
addressed and may contain information that is proprietary, privileged, company 
confidential
and/or exempt from disclosure under applicable law. If the reader is not the 
intended
recipient or agent responsible for delivering the message to the intended 
recipient, you are
hereby notified that any dissemination, distribution or copying of this 
communication is
strictly prohibited. If this communication has been transmitted from a U.S. 
location it may
also contain data subject to the International Traffic in Arms Regulations or 
U.S. Export
Administration Regulations and cannot be disseminated, distributed or copied to 
foreign
nationals, residing in the U.S. or abroad, without the prior approval of the 
U.S. Department
of State or appropriate export licensing authority. If you have received this 
communication
in error, please notify the sender by reply e-mail or collect telephone call 
and delete or
destroy all copies of this e-mail message, any physical copies made of this 
e-mail message
and/or any file attachment(s).

Reply via email to