3 min read

New Go library for working with your DBHub.io databases

For anyone with an interest in Go programming, there’s now a library to access and query your databases on DBHub.io:


Documentation is in place, code quality is good, and there are worked examples for each function call.

It’s still in early stages of development, but seems to work well already. 😄

What works now

  • Run read-only queries (eg SELECT statements) on databases, returning the results as JSON
  • List the tables, views, and indexes present in a database
  • List the columns in a table, view or index, along with their details
  • (Added 2020-08-02) - Generate a diff between two databases or revisions, to transform one into the other
  • (Added 2020-08-04) - List the branches of a database
  • (Added 2020-08-04) - Download a complete database
  • (Added 2020-08-05) - List the databases in your account
  • (Added 2020-08-05) - Download the database metadata (branches, releases, tags, commits, etc)

Still to do

  • Tests for each function
  • Upload a complete database
  • Investigate what would be needed for this to work through the Go SQL API
  • Anything else that people suggest and seems like a good idea 😄


  • Go version 1.14.x
    • Older Go releases should be ok, but only Go 1.14.x has been tested (so far).
  • A DBHub.io API key
    • These can be generated in your Settings page, when logged in.

Example code

// Create a new DBHub.io API object
db, err := dbhub.New("YOUR_API_KEY_HERE")
if err != nil {

// Retrieve the list of tables in the remote database
tables, err := db.Tables("justinclift", "Join Testing.sqlite")
if err != nil {

// Display the retrieved list of tables
for _, j := range tables {
    fmt.Printf("  * %s\n", j)

// Run a SQL query on the remote database
r, err := db.Query("justinclift", "Join Testing.sqlite", false,
    `SELECT table1.Name, table2.value
        FROM table1 JOIN table2
        USING (id)
        ORDER BY table1.id`)
if err != nil {
fmt.Printf("Query results (JSON):\n\t%v\n", r)


  * table1
  * table2

Query results (JSON):
        {[{[Foo 5]} {[Bar 10]} {[Baz 15]} {[Blumph 12.5000]} {[Blargo 8]} {[Batty 3]}]}

Further examples

Please try it out, submits PRs to extend or fix things, and report any weirdness or bugs you encounter. 😄