Skip to content

Commit b9fb334

Browse files
committed
Add Webpage() function, update dependencies and column_details example
1 parent 9ffd5f2 commit b9fb334

File tree

10 files changed

+48
-11
lines changed

10 files changed

+48
-11
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ A Go library for accessing and using SQLite databases stored remotely on DBHub.i
1515
* Generate diffs between two databases, or database revisions
1616
* Download a complete database
1717
* Download the database metadata (size, branches, commit list, etc.)
18+
* Retrieve the web page URL of the database
1819

1920
### Still to do
2021

21-
* A function for returning the web page URL of the database
2222
* Tests for each function
2323
* Have the backend server correctly use the incoming branch, release, and tag information
2424
* Upload a complete database
@@ -146,5 +146,6 @@ ORDER BY table1.id;
146146
* [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
147147
* [Download database](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/download_database/main.go) - Download the complete database file
148148
* [Retrieve metadata](https://github.com/sqlitebrowser/go-dbhub/blob/master/examples/metadata/main.go) - Download the database metadata (size, branches, commit list, etc)
149+
* [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
149150

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

dbhub.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,14 @@ func (c Connection) Views(dbOwner, dbName string, ident Identifier) (views []str
286286
err = sendRequestJSON(queryUrl, data, &views)
287287
return
288288
}
289+
290+
// Webpage returns the URL of the database file in the webUI. eg. for web browsers
291+
func (c Connection) Webpage(dbOwner, dbName string) (webPage com.WebpageResponseContainer, err error) {
292+
// Prepare the API parameters
293+
data := c.PrepareVals(dbOwner, dbName, Identifier{})
294+
295+
// Fetch the releases
296+
queryUrl := c.Server + "/v1/webpage"
297+
err = sendRequestJSON(queryUrl, data, &webPage)
298+
return
299+
}

examples/column_details/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ func main() {
2525
fmt.Printf("Columns on table or view '%s':\n", table)
2626
for _, j := range columns {
2727
fmt.Printf(" * '%v':\n", j.Name)
28-
fmt.Printf(" Autoincrement: %v\n", j.Autoinc)
2928
fmt.Printf(" Cid: %v\n", j.Cid)
30-
fmt.Printf(" Collation Sequence: %v\n", j.CollSeq)
3129
fmt.Printf(" Data Type: %v\n", j.DataType)
3230
fmt.Printf(" Default Value: %v\n", j.DfltValue)
3331
fmt.Printf(" Not Null: %v\n", j.NotNull)
3432
fmt.Printf(" Primary Key: %v\n", j.Pk)
3533
}
36-
fmt.Println()
3734
}

examples/list_views/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ func main() {
2525
for _, j := range views {
2626
fmt.Printf(" * %s\n", j)
2727
}
28-
fmt.Println()
2928
}

examples/webpage/main.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/sqlitebrowser/go-dbhub"
8+
)
9+
10+
func main() {
11+
// Create a new DBHub.io API object
12+
db, err := dbhub.New("YOUR_API_KEY_HERE")
13+
if err != nil {
14+
log.Fatal(err)
15+
}
16+
17+
// Retrieve the metadata for the remote database
18+
wp, err := db.Webpage("justinclift", "Join Testing.sqlite")
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
// Display the web page for the database
24+
fmt.Printf("Web page: '%s'\n", wp.WebPage)
25+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ replace (
1010
github.com/Sirupsen/logrus v1.6.0 => github.com/sirupsen/logrus v1.6.0
1111
)
1212

13-
require github.com/sqlitebrowser/dbhub.io v0.0.11
13+
require github.com/sqlitebrowser/dbhub.io v0.0.12

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e h1:qpG
123123
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
124124
github.com/sqlitebrowser/blackfriday v9.0.0+incompatible h1:ddH/UyzasooYgGIblVU4R8DdmBuJ7QXLvSqX/0chZv4=
125125
github.com/sqlitebrowser/blackfriday v9.0.0+incompatible/go.mod h1:/zga9sqpWzcewuI83AO5JZwe9+6F9GgPDdqqdNNEL/0=
126-
github.com/sqlitebrowser/dbhub.io v0.0.11 h1:Ddkjiftx/q5+ZFbOHIvuK6mQk1ACs/3jea7AbwDJlYA=
127-
github.com/sqlitebrowser/dbhub.io v0.0.11/go.mod h1:GgZi8wkjdRGkkUVgYNuZp5i+Yps3jGt/jjRuLKRi6Po=
126+
github.com/sqlitebrowser/dbhub.io v0.0.12 h1:G5qd4qQGCVB8/Seh0e+cBvaYkpnoGnWQuxPEr4B09ZE=
127+
github.com/sqlitebrowser/dbhub.io v0.0.12/go.mod h1:GgZi8wkjdRGkkUVgYNuZp5i+Yps3jGt/jjRuLKRi6Po=
128128
github.com/sqlitebrowser/github_flavored_markdown v0.0.0-20190120045821-b8cf8f054e47 h1:s0+Ea95n1LrsKh6rtclU/9Qb2/5ofvnfnR7gDDiFTw8=
129129
github.com/sqlitebrowser/github_flavored_markdown v0.0.0-20190120045821-b8cf8f054e47/go.mod h1:8vPIKi5FslxCXEgfQxrFtWfdclGy6VWAc9NA1ZTYCJg=
130130
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

vendor/github.com/sqlitebrowser/dbhub.io/common/responses.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/sqlitebrowser/dbhub.io/common/types.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ github.com/sourcegraph/annotate
6363
github.com/sourcegraph/syntaxhighlight
6464
# github.com/sqlitebrowser/blackfriday v9.0.0+incompatible
6565
github.com/sqlitebrowser/blackfriday
66-
# github.com/sqlitebrowser/dbhub.io v0.0.11
66+
# github.com/sqlitebrowser/dbhub.io v0.0.12
6767
## explicit
6868
github.com/sqlitebrowser/dbhub.io/common
6969
# github.com/sqlitebrowser/github_flavored_markdown v0.0.0-20190120045821-b8cf8f054e47

0 commit comments

Comments
 (0)