From: Eric Hodel Date: 2004-03-17T15:30:45-08:00 Subject: Re: Global $DBH? --Ublo+h3cBgJ33ahC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Mike J. (candiazoo@comcast.net) wrote: > I recently decided that for the sake of portability it might be better=20 > if I changed my app to not use the SQLite specific modules (ruby-sqlite= =20 > or sqlite-ruby, one of those) and instead made use of dbi. >=20 > Well, I quickly discovered that when using DBI.connect to my SQLite=20 > database, it locks it and none of the other classes in my app can open=20 > it to make extraneous queries. >=20 > SO... is there a "good" way (perhaps using BEGIN) to establish my=20 > database handle for use by all classes/modules within my application? =20 > I've fiddled with BEGIN but it seems to have scoping problems that I am= =20 > not familiar with (I am, btw, a relative newbie to Ruby, having been a=20 > Python person up until the last month or so). require 'singleton' Something like this should be re-workable into what you want: http://segment7.net/projects/ruby/snippets/database.rb --=20 Eric Hodel - drbrain@segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --Ublo+h3cBgJ33ahC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQFAWN+lMypVHHlsnwQRAtWGAJ9X+mSrlchy1WxK5rq512MTvffz0gCfc/If VajtIa6S4iL467wZ4H26dCU= =VQsH -----END PGP SIGNATURE----- --Ublo+h3cBgJ33ahC--