Skip to Content.
Sympa Menu

freetds - Re: [freetds] Using DBLIB With Azure

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] Using DBLIB With Azure
  • Date: Sat, 12 Mar 2011 08:36:16 -0500

On Wed, 9 Mar 2011 13:26:53 -0500
Ken Collins <ken AT metaskills.net> wrote:

> Azure does not have a notion of "USE ..." or has a way to specify a default
> database with the user account

https://github.com/rails-sqlserver/tiny_tds

OK, I think I finally get the picture.

If I understand aright, the TinyTds user -- an elf or gnome, perhaps? --
should be able to say something like this:

client = TinyTds::Client.new(:username => 'sa', :password => 'secret',
:dataserver => 'mytds_box', :database = 'mydb')

and you want to know how to deal with 'mydb'.

Simple: dbuse().

You're not obliged to use only one db-lib function when the connection is
established. Just call dblogin(), dbopen(), and dbuse(), in that order. Job
done.

If you really, really, really want to, you could extend db-lib. It's a mini
project:

1. add dbname to TDSLOGIN
2. add case to set dbname in dbsetlname
3. add macro DBSETLDBNAME
4. refer to TDSLOGIN::dbname when the structure is copied to TDSCONNECTION.

An alternative would be to add a new function, dbopendb(), that would take
three parameters instead of two.

Could be done, minorly useful. To a db-lib program, it's hard to see much
advantage to

DBSETLDB("mydb")
over
dbuse("mydb")

especially because dbuse() can fail, keeping the connection viable.

If you put the dbname in the login packet, you invite the ODBC problem -- I
say problem, but others might say feature -- of disallowing the connection
because the database name is wrong/unavailable. It's one of my (least)
favorite error messages: you can't login because the username/password is
invalid OR because you're not granted access to the database. Such, such are
the joys of troubleshooting. Nothing like ambiguity with your coffee.

But I'm sure the TinyTds user won't suffer the same. ;-)

HTH (this time).

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page