# Individual db connection per user?

**URL:** <https://www.ruby-forum.com/t/individual-db-connection-per-user/128105>\
**Category:** Rails\
**Created:** [February 5, 2008, 2:31am UTC](https://www.ruby-forum.com/t/individual-db-connection-per-user/128105 "2008-02-05T02:31:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shifra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@shifra](https://www.ruby-forum.com/u/shifra)\
**Post date:** [February 5, 2008, 2:31am UTC](https://www.ruby-forum.com/t/individual-db-connection-per-user/128105/1 "2008-02-05T02:31:04Z")

</div>

Hi all,

We have an SEC requirement that all connections to our app’s database  
be made with the credentials of the individual user who is logged in,  
not with the connection configured in the database.yml.

We know this is going to kill performance and have all kinds of  
undesirable side effects, but it’s a hard requirement. Before we start  
digging into Rails internals to figure out how to hack this, has  
anyone else solved it?

BTW, our db is Oracle, in case anyone knows how to make the initial  
connection and then act on behalf of the user (as if we were connected  
to the db with that username) for each request.

Thanks so much for any ideas,  
Shifra Pride Raffel and Parker T.  
Pivotal Labs

---

<div class="post-metadata">

**Author:** ![shifra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@shifra](https://www.ruby-forum.com/u/shifra)\
**Post date:** [February 5, 2008, 2:51am UTC](https://www.ruby-forum.com/t/individual-db-connection-per-user/128105/2 "2008-02-05T02:51:35Z")

</div>

On 5 Feb 2008, at 01:30, shifra wrote:

> anyone else solved it?  
> Call AR::Base.establish\_connection in an around/before\_filter ?

Fred
