Re: (Fwd) Perl DBI on Mac OS X

2011-05-11 Thread Alexander Foken

On 05.05.2011 10:50, Martin J. Evans wrote:


Clapper SQLCMD is a Python application that uses 
'/usr/local/lib/libmyodbc3.so'.


So do you want to connect to MS SQL Server or MySQL? You need 
different ODBC drivers for each.



Perl can also connect to MySQL using DBD::mysql, without needing an ODBC 
driver for MySQL. (But of course, you need the MySQL client libraries 
installed to compile DBD::mysql.)


Alexander

--
Alexander Foken
mailto:alexan...@foken.de  http://www.foken.de/alexander/



Re: (Fwd) Perl DBI on Mac OS X

2011-05-05 Thread six24hourdays
I am not explicitly requesting iODBC. I am trying to run the same test script, 
that works on my Windows machine, on a Mac machine.

The script has:

my $dsn = DBI:ODBC:Driver={SQL Server};Server=$server;Database=$db;

Is this correct for the Mac?

Thanks,
David
(sent from my personal account)



Re: (Fwd) Perl DBI on Mac OS X

2011-05-05 Thread six24hourdays
On May 3, 5:07 am, martin.ev...@easysoft.com (Martin J. Evans)
wrote:
 On 03/05/11 03:47, Tim Bunce wrote:









  - Forwarded message from david_st...@mcafee.com -

  Date: Mon, 2 May 2011 18:40:11 -0700 From: david_st...@mcafee.com To:
  tim.bu...@pobox.com Subject: Perl DBI on Mac OS X

  Hi Tim,

  Sorry to bother you. I am new to Perl DBI. I have it working fine on
  my Windows 7 box.

  I have installed the module on Ubuntu and tried running the same test
  script but get a connection error:

  DBI connect('Driver={SQL
  Server};Server=[dsn];Database=[db]','[pwd]',...) failed:
  [iODBC][Driver Manager]Specified driver could not be loaded
  (SQL-IM003) [state was IM003 now 0]

  [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found
  (SQL-0) at testDBI.pl line 14

  Can't connect to DBI:ODBC:Driver={SQL
  Server};Server=[dsn];Database=[db]: [iODBC][Driver Manager]Specified
  driver could not be loaded (SQL-IM003) [state was IM003 now 0]

  [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found
  (SQL-0) at testDBI.pl line 14.

  Do I need to install another module? Or configure ODBC?

  Thanks,

  David Stiff

  - End forwarded message -

 I don't use iODBC myself or a MAC but dlopen image not found suggests to me 
 that wherever your iODBC config file points the SQL Server entry to the 
 path/name of the shared object is wrong or you don't have all the 
 dependencies to load it (on Linux I'd run ldd on the shared object pointed to 
 but I don't know the equivalent on MAC).

 Martin
 --
 Martin J. Evans
 Easysoft Limitedhttp://www.easysoft.com

I am not explicitly specifying iODBC. I am using the same test script
from my Windows-box which has the line:

my $dsn = DBI:ODBC:Driver={SQL Server};Server=$server;Database=
$db;

Is this correct?

Thanks,
Dave (from my personal email account)



RE: (Fwd) Perl DBI on Mac OS X

2011-05-05 Thread David_Stiff
Clapper SQLCMD is a Python application that uses '/usr/local/lib/libmyodbc3.so'.

I think what it's boiling down to is that there is no ODBC driver on this Mac 
and I will have to purchase one.

Thanks,
Dave

From: Jonathan Leffler [mailto:jonathan.leff...@gmail.com]
Sent: Tuesday, May 03, 2011 2:09 PM
To: Stiff, David
Cc: dbi-users@perl.org
Subject: Re: (Fwd) Perl DBI on Mac OS X


On Tue, May 3, 2011 at 10:53, 
david_st...@mcafee.commailto:david_st...@mcafee.com wrote:
Comments in-line
Now you have to get down to - which ODBC drivers do you have installed?
 How can I check?

I don't know.  The chances are that if you're using iODBC, it has a way to do 
that - maybe via the isql tool.


Do you need the FreeTDS driver, for example?
 Probably not. Right now I am using 'sqlcmd' from Clapper Software. I may 
 have installed FreeTDS when I was initially trying to get DB access working. 
 However, I don't want to do anything that disables 'sqlcmd'.
So the Clapper SQLCMD program is able to connect?  Can you see the DSN 
(connection information) it is using?  If so, can you use that, or minor 
variations on that, to connect via other programs?

If you're using iODBC, the isql program should allow you to test connections.


What is the recommended course of action? Do I need to install/uninstall 
something? Or is it an ODBC configuration setting I need to change?

In my view (not by any means definitive since I've not actually done it for the 
setup you have), you should ensure that you can connect to the DBMS (DB) using 
just the ODBC software -- probably using isql or something similar.  Only when 
you have that ironed out should you try bringing Perl into the picture.

My general rule of thumb is:

* Get the DB connection working without Perl (+ DBI + DBD::WhatEver)
* Then get it working with Perl (+ DBI + DBD::WhatEver)

The DBD::Informix Makefile.PL enshrines that viewpoint - it compiles a test 
program to ensure that you have the software it needs and that you can connect 
to some test database before it creates the Makefile needed to build 
DBD::Informix.  It has saved me endless grief as we separate database 
connectivity issues in general from connectivity via Perl.  If you can't 
connect without Perl, there's no reason to think you'll be successful with 
Perl.  If you can connect without Perl, then the scope of the problems with 
Perl is generally simpler.


Good luck,
Jonathan


From: Jonathan Leffler 
[mailto:jonathan.leff...@gmail.commailto:jonathan.leff...@gmail.com]
Sent: Tuesday, May 03, 2011 11:47 AM
To: Stiff, David
Cc: dbi-users@perl.orgmailto:dbi-users@perl.org

Subject: Re: (Fwd) Perl DBI on Mac OS X


On Tue, May 3, 2011 at 08:15, 
david_st...@mcafee.commailto:david_st...@mcafee.com wrote:
Sorry. I meant to say Leopard, not Ubuntu.

MacOS X it is, then...

I am running a test script that lists the drivers and then connects to list the 
tables. I get this:

$ perl testdbi.plhttp://testdbi.pl

Driver: DBM
Driver: ExampleP
Driver: File
Driver: Gofer
Driver: ODBC
Driver: Proxy
Driver: Sponge

That says you've got the Perl + DBI + DBD::ODBC combination installed.  You 
even have an ODBC driver manager installed.

Now you have to get down to - which ODBC drivers do you have installed?

Do you need the FreeTDS driver, for example?


DBI connect('Driver={SQL 
Server};Server=database.domain.comhttp://database.domain.com;Database=MyDB','readonly',...)
 failed: [iODBC][Driver Manager]Specified driver could not be loaded 
(SQL-IM003) [state was IM003 now 0]
[iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0) at 
testdbi.plhttp://testdbi.pl line 14
Can't connect to DBI:ODBC:Driver={SQL 
Server};Server=database.domain.comhttp://database.domain.com;Database=MyDB: 
[iODBC][Driver Manager]Specified driver could not be loaded (SQL-IM003) [state 
was IM003 now 0]
[iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0) at 
testdbi.plhttp://testdbi.pl line 14.

Thanks,
David

From: Jonathan Leffler 
[mailto:jonathan.leff...@gmail.commailto:jonathan.leff...@gmail.com]
Sent: Tuesday, May 03, 2011 10:27 AM
To: Stiff, David; dbi-users@perl.orgmailto:dbi-users@perl.org
Subject: Re: (Fwd) Perl DBI on Mac OS X (or Ubuntu?)


On Mon, May 2, 2011 at 19:47, Tim Bunce 
tim.bu...@pobox.commailto:tim.bu...@pobox.com wrote:
- Forwarded message from 
david_st...@mcafee.commailto:david_st...@mcafee.com -

Date: Mon, 2 May 2011 18:40:11 -0700
From: david_st...@mcafee.commailto:david_st...@mcafee.com
To: tim.bu...@pobox.commailto:tim.bu...@pobox.com
Subject: Perl DBI on Mac OS X

  [...] I am new to Perl DBI. I have it working fine on my Windows 7 box.

  I have installed the module on Ubuntu and tried running the same test script 
but get a connection error:

Your subject line says 'MacOS X'; your comment here says 'Ubuntu'.  AFAIK, 
those are not synonyms.

Which platform are you actually having the problems on?

  DBI connect('Driver={SQL Server};Server=[dsn];Database

RE: (Fwd) Perl DBI on Mac OS X

2011-05-05 Thread David_Stiff
Comments in-line

Now you have to get down to - which ODBC drivers do you have installed?
 How can I check?

Do you need the FreeTDS driver, for example?
 Probably not. Right now I am using 'sqlcmd' from Clapper Software. I may 
 have installed FreeTDS when I was initially trying to get DB access working. 
 However, I don't want to do anything that disables 'sqlcmd'.
What is the recommended course of action? Do I need to install/uninstall 
something? Or is it an ODBC configuration setting I need to change?

Thanks!
Dave


From: Jonathan Leffler [mailto:jonathan.leff...@gmail.com]
Sent: Tuesday, May 03, 2011 11:47 AM
To: Stiff, David
Cc: dbi-users@perl.org
Subject: Re: (Fwd) Perl DBI on Mac OS X


On Tue, May 3, 2011 at 08:15, 
david_st...@mcafee.commailto:david_st...@mcafee.com wrote:
Sorry. I meant to say Leopard, not Ubuntu.

MacOS X it is, then...

I am running a test script that lists the drivers and then connects to list the 
tables. I get this:

$ perl testdbi.plhttp://testdbi.pl

Driver: DBM
Driver: ExampleP
Driver: File
Driver: Gofer
Driver: ODBC
Driver: Proxy
Driver: Sponge

That says you've got the Perl + DBI + DBD::ODBC combination installed.  You 
even have an ODBC driver manager installed.

Now you have to get down to - which ODBC drivers do you have installed?

Do you need the FreeTDS driver, for example?


DBI connect('Driver={SQL 
Server};Server=database.domain.comhttp://database.domain.com;Database=MyDB','readonly',...)
 failed: [iODBC][Driver Manager]Specified driver could not be loaded 
(SQL-IM003) [state was IM003 now 0]
[iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0) at 
testdbi.plhttp://testdbi.pl line 14
Can't connect to DBI:ODBC:Driver={SQL 
Server};Server=database.domain.comhttp://database.domain.com;Database=MyDB: 
[iODBC][Driver Manager]Specified driver could not be loaded (SQL-IM003) [state 
was IM003 now 0]
[iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0) at 
testdbi.plhttp://testdbi.pl line 14.

Thanks,
David

From: Jonathan Leffler 
[mailto:jonathan.leff...@gmail.commailto:jonathan.leff...@gmail.com]
Sent: Tuesday, May 03, 2011 10:27 AM
To: Stiff, David; dbi-users@perl.orgmailto:dbi-users@perl.org
Subject: Re: (Fwd) Perl DBI on Mac OS X (or Ubuntu?)


On Mon, May 2, 2011 at 19:47, Tim Bunce 
tim.bu...@pobox.commailto:tim.bu...@pobox.com wrote:
- Forwarded message from 
david_st...@mcafee.commailto:david_st...@mcafee.com -

Date: Mon, 2 May 2011 18:40:11 -0700
From: david_st...@mcafee.commailto:david_st...@mcafee.com
To: tim.bu...@pobox.commailto:tim.bu...@pobox.com
Subject: Perl DBI on Mac OS X

  [...] I am new to Perl DBI. I have it working fine on my Windows 7 box.

  I have installed the module on Ubuntu and tried running the same test script 
but get a connection error:

Your subject line says 'MacOS X'; your comment here says 'Ubuntu'.  AFAIK, 
those are not synonyms.

Which platform are you actually having the problems on?

  DBI connect('Driver={SQL Server};Server=[dsn];Database=[db]','[pwd]',...) 
failed: [iODBC][Driver
  Manager]Specified driver could not be loaded (SQL-IM003) [state was IM003 now 
0]

  [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0) 
at testDBI.pl line 14

  Can't connect to DBI:ODBC:Driver={SQL Server};Server=[dsn];Database=[db]: 
[iODBC][Driver
  Manager]Specified driver could not be loaded (SQL-IM003) [state was IM003 now 
0]

  [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0) 
at testDBI.pl line 14.

  Do I need to install another module? Or configure ODBC?


Can you write a pure ODBC program that connects to your database?  If so, what 
DSN do you use to connect?
If not, concentrate on configuring ODBC correctly.  Do you have an ODBC driver 
for your DBMS installed?

Is your DBMS running on your Ubuntu (MacOS X) box or out on a Windows box?

--
Jonathan Leffler 
jonathan.leff...@gmail.commailto:jonathan.leff...@gmail.com  #include 
disclaimer.h
Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
Blessed are we who can laugh at ourselves, for we shall never cease to be 
amused.


Re: (Fwd) Perl DBI on Mac OS X

2011-05-05 Thread Martin J. Evans

David,

I'm quickly losing track of where you are because you answered so many posts 
from days ago trying to help you and now mysql seems to be mentioned. Let me 
try and explain some of what you are doing and why it might be going wrong.

I am not explicitly specifying iODBC

When DBD::ODBC was built (maybe not by you) or installed from some MAC package it was 
linked against an ODBC driver manager. The ODBC Driver manager is what loads the ODBC 
driver when you call connect. Your error contained [iODBC][Driver Manager] so 
I think you are using the iODBC Driver Manager which is a common one in use on Macs.

Specified driver could not be loaded
when you used a connect string of DBI:ODBC:Driver={SQL 
Server};Server=$server;Database=$db

The first thing to note here is that the DBI should be dbi so if this 
connect string was copied from Windows it cannot be working there either.

The second thing is that what you are requesting the iODBC driver manager to do if find the ODBC 
Driver called SQL Server and load it with dlopen. When you do this iODBC needs to 
locate the path to the driver shared object for the driver called SQL Server and iODBC 
uses a configuration file to tie drivers to shared objects - probably iodbc.ini. Whatever is in 
your iODBC config files points it at a shared object which cannot be loaded. I don't use iODBC so I 
don't know what it does if it cannot find a driver but given the last error mentions dlopen it 
suggests to me:

1. you have an iODBC configuration file that iODBC knows about
2. it contains a definition for the driver SQL Server
3. it contains a driver key for SQL Server which points at some file
4. dlopen cannot load the file named in 3.

4 fails because of:

1. file does not exist
2. shared object exists but permissions are wrong
3. shared object exists and permissions ok but it depends on something else 
either not on your system or not in your path or having problem 2

Given your error was dlopen({SQL Server}, 6): image not found I'd suggest 1.

Other things you said in other replies:


I am running a test script that lists the drivers and then connects to list the 
tables. I get this:

$ perl testdbi.pl

Driver: DBM
Driver: ExampleP
Driver: File
Driver: Gofer
Driver: ODBC
Driver: Proxy
Driver: Sponge

DBI connect('Driver={SQL 
Server};Server=database.domain.com;Database=MyDB','readonly',...) failed: 
[iODBC][Driver Manager]Specified driver could not be loaded (SQL-IM003) [state 
was IM003 now 0]


I cannot see who that script automatically knows to use Driver={SQL Server} 
etc in that connect string - this muct be hard-coded in your script somewhere.


What is the recommended course of action? Do I need to install/uninstall 
something? Or is it an ODBC configuration setting I need to change?


To use DBD::ODBC you need an ODBC Driver. It sounds like you at least have parts of a 
driver since iODBC seems to think you have a driver called SQL Server. You 
need to find the iODBC config file and see what it says. To connect to MS SQL Server you 
will need an ODBC driver that talks to MS SQL Server such as freeTDS or other commercial 
solutions. BTW, I think there is a GUI config program for iODBC - try fining that.


Clapper SQLCMD is a Python application that uses '/usr/local/lib/libmyodbc3.so'.


So do you want to connect to MS SQL Server or MySQL? You need different ODBC 
drivers for each.

Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com


Re: (Fwd) Perl DBI on Mac OS X

2011-05-03 Thread Martin J. Evans

On 03/05/11 03:47, Tim Bunce wrote:

- Forwarded message from david_st...@mcafee.com -

Date: Mon, 2 May 2011 18:40:11 -0700 From: david_st...@mcafee.com To:
tim.bu...@pobox.com Subject: Perl DBI on Mac OS X

Hi Tim,

Sorry to bother you. I am new to Perl DBI. I have it working fine on
my Windows 7 box.

I have installed the module on Ubuntu and tried running the same test
script but get a connection error:

DBI connect('Driver={SQL
Server};Server=[dsn];Database=[db]','[pwd]',...) failed:
[iODBC][Driver Manager]Specified driver could not be loaded
(SQL-IM003) [state was IM003 now 0]

[iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found
(SQL-0) at testDBI.pl line 14

Can't connect to DBI:ODBC:Driver={SQL
Server};Server=[dsn];Database=[db]: [iODBC][Driver Manager]Specified
driver could not be loaded (SQL-IM003) [state was IM003 now 0]

[iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found
(SQL-0) at testDBI.pl line 14.

Do I need to install another module? Or configure ODBC?

Thanks,

David Stiff

- End forwarded message -


I don't use iODBC myself or a MAC but dlopen image not found suggests to me that 
wherever your iODBC config file points the SQL Server entry to the path/name of the 
shared object is wrong or you don't have all the dependencies to load it (on Linux I'd run ldd on 
the shared object pointed to but I don't know the equivalent on MAC).

Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com


Re: (Fwd) Perl DBI on Mac OS X

2011-05-03 Thread Jonathan Leffler
On Tue, May 3, 2011 at 10:53, david_st...@mcafee.com wrote:

 Comments in-line

 Now you have to get down to - which ODBC drivers do you have installed?
  How can I check?


I don't know.  The chances are that if you're using iODBC, it has a way to
do that - maybe via the isql tool.



 Do you need the FreeTDS driver, for example?

  Probably not. Right now I am using ‘sqlcmd’ from Clapper Software. I may
 have installed FreeTDS when I was initially trying to get DB access working.
 However, I don’t want to do anything that disables ‘sqlcmd’.

 So the Clapper SQLCMD program is able to connect?  Can you see the DSN
(connection information) it is using?  If so, can you use that, or minor
variations on that, to connect via other programs?

If you're using iODBC, the isql program should allow you to test
connections.



 What is the recommended course of action? Do I need to install/uninstall
 something? Or is it an ODBC configuration setting I need to change?


In my view (not by any means definitive since I've not actually done it for
the setup you have), you should ensure that you can connect to the DBMS (DB)
using just the ODBC software -- probably using isql or something similar.
Only when you have that ironed out should you try bringing Perl into the
picture.

My general rule of thumb is:

* Get the DB connection working without Perl (+ DBI + DBD::WhatEver)
* Then get it working with Perl (+ DBI + DBD::WhatEver)

The DBD::Informix Makefile.PL enshrines that viewpoint - it compiles a test
program to ensure that you have the software it needs and that you can
connect to some test database before it creates the Makefile needed to build
DBD::Informix.  It has saved me endless grief as we separate database
connectivity issues in general from connectivity via Perl.  If you can't
connect without Perl, there's no reason to think you'll be successful with
Perl.  If you can connect without Perl, then the scope of the problems with
Perl is generally simpler.


Good luck,
Jonathan



 *From:* Jonathan Leffler [mailto:jonathan.leff...@gmail.com]
 *Sent:* Tuesday, May 03, 2011 11:47 AM
 *To:* Stiff, David
 *Cc:* dbi-users@perl.org

 *Subject:* Re: (Fwd) Perl DBI on Mac OS X





 On Tue, May 3, 2011 at 08:15, david_st...@mcafee.com wrote:

 Sorry. I meant to say Leopard, not Ubuntu.


 MacOS X it is, then...


 I am running a test script that lists the drivers and then connects to list
 the tables. I get this:



 *$ perl testdbi.pl *



 Driver: DBM

 Driver: ExampleP

 Driver: File

 Driver: Gofer

 Driver: ODBC

 Driver: Proxy

 Driver: Sponge


 That says you've got the Perl + DBI + DBD::ODBC combination installed.  You
 even have an ODBC driver manager installed.

 Now you have to get down to - which ODBC drivers do you have installed?

 Do you need the FreeTDS driver, for example?




 DBI connect('Driver={SQL 
 Server};Server=database.domain.com;Database=MyDB','readonly',...)
 failed: [iODBC][Driver Manager]Specified driver could not be loaded
 (SQL-IM003) [state was IM003 now 0]

 [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0)
 at testdbi.pl line 14

 Can't connect to DBI:ODBC:Driver={SQL 
 Server};Server=database.domain.com;Database=MyDB:
 [iODBC][Driver Manager]Specified driver could not be loaded (SQL-IM003)
 [state was IM003 now 0]

 [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (SQL-0)
 at testdbi.pl line 14.



 Thanks,

 David



 *From:* Jonathan Leffler [mailto:jonathan.leff...@gmail.com]
 *Sent:* Tuesday, May 03, 2011 10:27 AM
 *To:* Stiff, David; dbi-users@perl.org
 *Subject:* Re: (Fwd) Perl DBI on Mac OS X (or Ubuntu?)





 On Mon, May 2, 2011 at 19:47, Tim Bunce tim.bu...@pobox.com wrote:

 - Forwarded message from david_st...@mcafee.com -

 Date: Mon, 2 May 2011 18:40:11 -0700
 From: david_st...@mcafee.com
 To: tim.bu...@pobox.com
 Subject: Perl DBI on Mac OS X

   [...] I am new to Perl DBI. I have it working fine on my Windows 7 box.

   I have installed the module on Ubuntu and tried running the same test
 script but get a connection error:


 Your subject line says 'MacOS X'; your comment here says 'Ubuntu'.  AFAIK,
 those are not synonyms.

 Which platform are you actually having the problems on?


   DBI connect('Driver={SQL Server};Server=[dsn];Database=[db]','[pwd]',...)
 failed: [iODBC][Driver
   Manager]Specified driver could not be loaded (SQL-IM003) [state was IM003
 now 0]

   [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found
 (SQL-0) at testDBI.pl line 14

   Can't connect to DBI:ODBC:Driver={SQL Server};Server=[dsn];Database=[db]:
 [iODBC][Driver
   Manager]Specified driver could not be loaded (SQL-IM003) [state was IM003
 now 0]

   [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found
 (SQL-0) at testDBI.pl line 14.

   Do I need to install another module? Or configure ODBC?



 Can you write a pure ODBC program that connects to your database?  If so,
 what DSN do you use