# Dynamic database connection

**URL:** <https://www.ruby-forum.com/t/dynamic-database-connection/161341>\
**Category:** Rails\
**Created:** [February 25, 2009, 5:49pm UTC](https://www.ruby-forum.com/t/dynamic-database-connection/161341 "2009-02-25T17:49:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rickf](https://www.ruby-forum.com/u/rickf)\
**Post date:** [February 25, 2009, 5:49pm UTC](https://www.ruby-forum.com/t/dynamic-database-connection/161341/1 "2009-02-25T17:49:07Z")

</div>

Hi All,

Is there a way to determine the adapter type, as well as, other  
information on the fly for a database? For example, can you make a  
generic type connection to a database (assuming the db server port  
and/or credentials are correct) and ask the db information about itself,  
then based on the response configure the establish\_connection  
accordingly? The initial generic connection would not access the actual  
data for ROR, but determine the information about the DB for use with  
ROR.

One approach is to attempt to access the DB cycling through the  
available adapter types until you get a response, however, this seems  
clunky at best.

Any thoughts are appreciated.

thanks for any advice,  
Rick

---

<div class="post-metadata">

**Author:** ![rickf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rickf](https://www.ruby-forum.com/u/rickf)\
**Post date:** [February 25, 2009, 6:00pm UTC](https://www.ruby-forum.com/t/dynamic-database-connection/161341/2 "2009-02-25T18:00:08Z")

</div>

On 25 Feb 2009, at 16:49, Rick F. wrote:

> actual  
> data for ROR, but determine the information about the DB for use with  
> ROR.
> 
> One approach is to attempt to access the DB cycling through the  
> available adapter types until you get a response, however, this seems  
> clunky at best.

You probably could - tools like nmap can probably tell the difference  
between mysql running on port x, postgresql running on that same port  
etc…  
It seems like quite a lot of effort for a onetime setup job though  
(unless you’re very focussed on that wow it works straight out of the  
box experience)

Fred
