Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Perl, DBD and SQL Server 2008 (R2)

by mje (Curate)
on Feb 03, 2011 at 09:47 UTC ( #885941=note: print w/ replies, xml ) Need Help??


in reply to Perl, DBD and SQL Server 2008 (R2)

Just to add one little bit to the excellent information roboticus provided as it sometimes confuses people. When you use "dbi:ODBC:mydsn" DBD::ODBC actually calls the SQLConnect ODBC API first with the DSN mydsn and only if that fails does it call the SQLDriverConnect ODBC API. The SQLConnect API is old, still called for backwards compatibility and does not support connection attributes of the form "a=b;c=d". If you want to skip the call to SQLConnect and go immediately to SQLDriverConnect then use "dbi:ODBC:DSN=mydsn" or "dbi:ODBC:DRIVER={xxx}".


Comment on Re: Perl, DBD and SQL Server 2008 (R2)
Re^2: Perl, DBD and SQL Server 2008 (R2)
by campblem (Initiate) on Feb 03, 2011 at 18:51 UTC
    Thanks so much everyone. We have installed FreeTDS. I can execute, at the command line:
    tsql -S ODBC -U myDatabaseName
    I get prompted for a username and password, and can log in and execute commands against the database. So I know I can connect.
    What I can't find in the documentation is WHERE DBI looks for its available_drivers. For example, I should expect that FreeTDS would show up in my DBI->avialable_drivers() call...but it doesn't.
    We keep updating the configuration in /etc/odbc.ini; now it looks like we need to update /usr/local/etc/freeTDS.conf.
    We will keep looking.
    Many thanks for your kind help.
    Emily

      DBI's available_drivers only lists available DBDs e.g., DBD::ODBC, DBD::Pg (the DBDs installed on your machine not ODBC drivers). If you are using DBD::ODBC the DBI method data_sources returns valid ODBC data sources (which I think you are looking for) and this info comes from the ODBC Driver manager and the SQLDataSources ODBC call. This is usually a list of data sources in one or more odbc.ini files. The odbcinst.ini file (if using unixODBC) lists available ODBC drivers on your machine - see the links I gave before - they explain all this.

        I use freetds/unixodbc on a hp-ux platform. I find perl scripts looks in the user home directory (~) for a .odbc.ini file. So, as the user that is executing the script, check ~/.odbc.ini to make sure its there. Hope this helps!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://885941]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-12-29 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls