GDBC — Go Database Connectivity

Burak Köken
2 min readJan 24, 2021

--

GDBC Logo

Today, we’re going to talk about GDBC. What exactly is this?

As you know, Data Source Name, known as DSN does not have any standard format and all the driver libraries have their driver-specific DSN. Sometimes you might get confused about how to specify your DSN for the database you want to connect to. In order to solve this issue, GDBC provides a common format to represent the database and an abstract layer for database connections.

Gopher Artworks

With GDBC, a database is represented by a URL (Uniform Resource Locator). URL takes one of the following forms:

gdbc:driver-name:database-name?arg1=value1&arg2=value...
gdbc:driver-name://host/database-name?arg1=value1&arg2=value...
gdbc:driver-name://host:port/database?arg1=value1&arg2=value...
gdbc:driver-name://username:password@host:port/database-name?arg1=value1&arg2=value...
...

How to use GDBC?

It’s pretty easy to connect the database using GDBC. Depending on which database you use, you can connect to the database by using the GDBC driver and specifying GDBC URL as shown below

  • GetDataSource returns the data source which you can get a database connection.
  • GetConnection returns the database connection.

GDBC officially supports databases MySQL, PostgreSQL, SQLite, SQL Server. Checkout for details.

Hopefully, you got a basic understanding of GDBC.

HAPPY CODING…

You can find the code on Github. And if you would like to contribute to the library or you find a bug, please report it.

--

--

No responses yet