# How to get a connection with an existent database?

**URL:** <https://www.ruby-forum.com/t/how-to-get-a-connection-with-an-existent-database/140282>\
**Category:** Ruby\
**Created:** [June 12, 2008, 4:32pm UTC](https://www.ruby-forum.com/t/how-to-get-a-connection-with-an-existent-database/140282 "2008-06-12T16:32:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peyisar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@peyisar](https://www.ruby-forum.com/u/peyisar)\
**Post date:** [June 12, 2008, 4:32pm UTC](https://www.ruby-forum.com/t/how-to-get-a-connection-with-an-existent-database/140282/1 "2008-06-12T16:32:36Z")

</div>

Can somebody say me how to read an existent database with sqlite and  
ruby? I want to know, how to get the connection and then close it.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![peyisar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@peyisar](https://www.ruby-forum.com/u/peyisar)\
**Post date:** [June 12, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/how-to-get-a-connection-with-an-existent-database/140282/2 "2008-06-12T16:45:22Z")

</div>

On Thu, Jun 12, 2008 at 8:32 AM, Ignacio G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Can somebody say me how to read an existent database with sqlite and  
> ruby? I want to know, how to get the connection and then close it.
> 
> ## Thanks 🙂
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

You could always use the SQLite gem ([http://sqlite-ruby.rubyforge.org/](http://sqlite-ruby.rubyforge.org/))

–  
“Hey brother Christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![peyisar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@peyisar](https://www.ruby-forum.com/u/peyisar)\
**Post date:** [June 13, 2008, 9:32am UTC](https://www.ruby-forum.com/t/how-to-get-a-connection-with-an-existent-database/140282/3 "2008-06-13T09:32:20Z")

</div>

Glen H. wrote:

> On Thu, Jun 12, 2008 at 8:32 AM, Ignacio G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Can somebody say me how to read an existent database with sqlite and  
> > ruby? I want to know, how to get the connection and then close it.
> > 
> > ## Thanks 🙂
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> You could always use the SQLite gem ([http://sqlite-ruby.rubyforge.org/](http://sqlite-ruby.rubyforge.org/))
> 
> –  
> “Hey brother Christian with your high and mighty errand, Your actions  
> speak  
> so loud, I can’t hear a word you’re saying.”
> 
> -Greg Graffin (Bad Religion)

I ve looked teh SQLite gem, but there donÂ´t say how to get a connection  
with an existent database. All time itÂ´s creating the database… :(.

---

<div class="post-metadata">

**Author:** ![peyisar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@peyisar](https://www.ruby-forum.com/u/peyisar)\
**Post date:** [June 13, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/how-to-get-a-connection-with-an-existent-database/140282/4 "2008-06-13T16:15:26Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Ignacio G. wrote:  
|  
| I ve looked teh SQLite gem, but there donÂ´t say how to get a connection  
| with an existent database. All time itÂ´s creating the database… :(.

Then you didn’t look close enough. If the file/db doesn’t exist, it will  
be created. Otherwise, the SQLite gem will use the existing database.

* * *

Phillip G.  
Twitter: [twitter.com/cynicalryan](http://twitter.com/cynicalryan)  
Blog: [http://justarubyist.blogspot.com](http://justarubyist.blogspot.com)

10 years ago I was so ignorant, I didn’t even know who the  
Prime Minister of America was.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.8 (MingW32)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iEYEARECAAYFAkhSgNoACgkQbtAgaoJTgL+OUwCfZg6AXyZsuxr0BIfr7pA2YerE  
nDAAn0/KwODgsSEsOfyMVX1UcxXxPtC1  
=De9U  
-----END PGP SIGNATURE-----
