{"id":20508659,"url":"https://github.com/sqlitebrowser/go-dbhub","last_synced_at":"2025-04-13T22:09:07.971Z","repository":{"id":57536610,"uuid":"282700903","full_name":"sqlitebrowser/go-dbhub","owner":"sqlitebrowser","description":"A Go library for accessing and using SQLite databases on DBHub.io","archived":false,"fork":false,"pushed_at":"2024-01-16T22:02:22.000Z","size":2814,"stargazers_count":20,"open_issues_count":0,"forks_count":12,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-13T22:08:39.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sqlitebrowser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-26T17:36:36.000Z","updated_at":"2025-03-28T14:40:47.000Z","dependencies_parsed_at":"2024-01-17T01:08:34.707Z","dependency_job_id":null,"html_url":"https://github.com/sqlitebrowser/go-dbhub","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlitebrowser%2Fgo-dbhub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlitebrowser%2Fgo-dbhub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlitebrowser%2Fgo-dbhub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlitebrowser%2Fgo-dbhub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqlitebrowser","download_url":"https://codeload.github.com/sqlitebrowser/go-dbhub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788939,"owners_count":21161727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T20:19:44.494Z","updated_at":"2025-04-13T22:09:07.728Z","avatar_url":"https://github.com/sqlitebrowser.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/sqlitebrowser/go-dbhub?status.svg)](https://godoc.org/github.com/sqlitebrowser/go-dbhub)\n[![Go Report Card](https://goreportcard.com/badge/github.com/sqlitebrowser/go-dbhub)](https://goreportcard.com/report/github.com/sqlitebrowser/go-dbhub)\n\nA Go library for accessing and using SQLite databases stored remotely on DBHub.io\n\n### What works now\n\n* (Experimental) Upload, delete, and list your \"Live\" databases\n* (Experimental) Execute INSERT/UPDATE/DELETE statements on your \"Live\" databases\n* (Experimental) List the tables, views, indexes, and columns in your \"Live\" databases\n* Run read-only queries (eg SELECT statements) on databases, returning the results as JSON\n* Upload and download your databases\n* List the databases in your account\n* List the tables, views, and indexes present in a database\n* List the columns in a table, view or index, along with their details\n* List the branches, releases, tags, and commits for a database\n* Generate diffs between two databases, or database revisions\n* Download the database metadata (size, branches, commit list, etc.)\n* Retrieve the web page URL of a database\n\n### Still to do\n\n* Have the backend server correctly use the incoming branch, release, and tag information\n* Tests for each function\n* Investigate what would be needed for this to work through the Go SQL API\n  * Probably need to improve the Query approach, to at least support placeholders and argument parameters\n* Anything else people suggest and seems like a good idea :smile:\n\n### Requirements\n\n* [Go](https://golang.org/dl/) version 1.17 or above\n* A DBHub.io API key\n  * These can be generated in your [Settings](https://dbhub.io/pref) page, when logged in.\n\n### Example code\n\n#### Create a new DBHub.io API object\n\n```\ndb, err := dbhub.New(\"YOUR_API_KEY_HERE\")\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n#### Retrieve the list of tables in a remote database\n```\n// Run the `Tables()` function on the new API object\ntables, err := db.Tables(\"justinclift\", \"Join Testing.sqlite\", dbhub.Identifier{Branch: \"master\"})\nif err != nil {\n    log.Fatal(err)\n}\n\n// Display the retrieved list of tables\nfmt.Println(\"Tables:\")\nfor _, j := range tables {\n    fmt.Printf(\"  * %s\\n\", j)\n}\n```\n\n##### Output\n```\nTables:\n  * table1\n  * table2\n```\n\n#### Run a SQL query on a remote database\n```\n// Do we want to display BLOBs as base64?\nshowBlobs := false\n\n// Run the query\nresult, err := db.Query(\"justinclift\", \"Join Testing.sqlite\",\n    dbhub.Identifier{ Branch: \"master\" }, showBlobs,\n    `SELECT table1.Name, table2.value\n    FROM table1 JOIN table2\n    USING (id)\n    ORDER BY table1.id`)\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Printf(\"Query results (JSON):\\n\\t%v\\n\", result)\nfmt.Println()\n```\n\n##### Output\n```\nQuery results (JSON):\n        {[{[Foo 5]} {[Bar 10]} {[Baz 15]} {[Blumph 12.5000]} {[Blargo 8]} {[Batty 3]}]}\n```\n\n#### Generate and display the difference between two commits of a remote database\n```\n// The databases we want to see differences for\ndb1Owner := \"justinclift\"\ndb1Name := \"Join Testing.sqlite\"\ndb1Commit := dbhub.Identifier{\n    CommitID: \"c82ba65add364427e9af3f540be8bf98e8cd6bdb825b07c334858e816c983db0\" }\ndb2Owner := \"\"\ndb2Name := \"\"\ndb2Commit := dbhub.Identifier{\n    CommitID: \"adf78104254ece17ff40dab80ae800574fa5d429a4869792a64dcf2027cd9cd9\" }\n\n// Create the diff\ndiffs, err := db.Diff(db1Owner, db1Name, db1Commit, db2Owner, db2Name, db2Commit,\n    dbhub.PreservePkMerge)\nif err != nil {\n    log.Fatal(err)\n}\n\n// Display the diff\nfmt.Printf(\"SQL statements for turning the first commit into the second:\\n\")\nfor _, i := range diffs.Diff {\n    if i.Schema != nil {\n        fmt.Printf(\"%s\\n\", i.Schema.Sql)\n    }\n    for _, j := range i.Data {\n        fmt.Printf(\"%s\\n\", j.Sql)\n    }\n}\n```\n\n##### Output\n```\nSQL statements for turning the first commit into the second:\nCREATE VIEW joinedView AS\nSELECT table1.Name, table2.value\nFROM table1 JOIN table2\nUSING (id)\nORDER BY table1.id;\n```\n\n### Further examples\n\n* [SQL Query](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/sql_query/main.go) - Run a SQL query, return the results as JSON\n* [List databases](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_databases/main.go) - List the databases present in your account\n* [List tables](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_tables/main.go) - List the tables present in a database\n* [List views](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_views/main.go) - List the views present in a database\n* [List indexes](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_indexes/main.go) - List the indexes present in a database\n* [Retrieve column details](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/column_details/main.go) - Retrieve the details of columns in a table\n* [List branches](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_branches/main.go) - List all branches of a database\n* [List releases](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_releases/main.go) - Display the releases for a database\n* [List tags](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_tags/main.go) - Display the tags for a database\n* [List commits](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/list_commits/main.go) - Display the commits for a database\n* [Generate diff between two revisions](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/diff_commits/main.go) - Figure out the differences between two databases or two versions of one database\n* [Upload database](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/upload/main.go) - Upload a new database file\n* [Download database](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/download_database/main.go) - Download the complete database file\n* [Delete database](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/delete_database/main.go) - Delete a database\n* [Retrieve metadata](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/metadata/main.go) - Download the database metadata (size, branches, commit list, etc)\n* [Web page](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/webpage/main.go) - Get the URL of the database file in the webUI.  eg. for web browsers\n\nPlease try it out, submits PRs to extend or fix things, and report any weirdness or bugs you encounter. :smile:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlitebrowser%2Fgo-dbhub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqlitebrowser%2Fgo-dbhub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlitebrowser%2Fgo-dbhub/lists"}