In Goby we have a built in database library for easily connecting to databased. It should be an universal interface for any kind of SQL database, but we currently only support
postgresql's driver. And To use database library, you need to require it first.
Retrieve a database connection
You can use
DB.open to open a new database connection and get a
DB class's instance. The
open method's first argument is the database adapter's name (currently only
postgres), and the second argument is the options for this connection like username, password, database name or sslmode...etc.
require "db" connection = DB.open("postgres", "user=postgres dbname=goby_test sslmode=disable")
To verify the connection, you can use
#ping method. It returns
true if the connection is workable, and returns
false if anything goes wrong (I will change the returned result to provide more detailed informations in the future).