Per Session Database Connection

Hi,

I am creating a Rails front-end for a legacy application. For this
application the username and password for the database must be provided
by the user. i.e. each session needs a separate connection to the
database using the credentials of the user logged in to that session.

Does anyone have any idea where to even start? It seems like Rails won’t
boot without a database configured (it fails in initializer.rb if you
don’t specify a DB). The problem I have is that until the user actually
enters their name and password I have no way to log in to the DB.

Thanks,

Chris.

On 7/14/06, Chris [email protected] wrote:

enters their name and password I have no way to log in to the DB.

You might want to post what database you are using, some solutions are
database specific. For example with postgres you could use SET
SESSION AUTHORIZATION and just use one connection.

snacktime wrote:

You might want to post what database you are using, some solutions are
database specific. For example with postgres you could use SET
SESSION AUTHORIZATION and just use one connection.

At the moment I am using Firebird, but ideally I would like a DB
independent solution.

At the moment I am experimenting with the per-model connection technique
from here:

http://wiki.rubyonrails.org/rails/pages/HowtoUseMultipleDatabases

but I am bit nervous about the impact of connection pooling and caching.
Since I am doing this for security reasons, having a cached connection
be used by another session would be catastrophic.

Thanks,

Chris.