Back to

Package dbhub

v0.0.0 (80d7e68)
Latest Go to latest
Published: today | License: MIT | Module:


Package Files

type Connection

type Connection struct {
	APIKey string `json:"api_key"`
	Server string `json:"server"`

Connection is a simple container holding the API key and address of the server

func New

func New(key string) (Connection, error)

New creates a new connection object. It doesn't connect to to do this. Connection only occurs when subsequent functions (eg Query()) are called.

func (*Connection) ChangeAPIKey

func (c *Connection) ChangeAPIKey(k string)

ChangeAPIKey updates the API key used for authenticating with

func (*Connection) ChangeServer

func (c *Connection) ChangeServer(s string)

ChangeServer changes the address for communicating with Useful for testing and development.

func (Connection) Columns

func (c Connection) Columns(dbOwner, dbName string, ident Identifier, table string) (columns []com.APIJSONColumn, err error)

Columns returns the column information for a given table or view

func (Connection) Diff

func (c Connection) Diff(dbOwnerA, dbNameA string, identA Identifier, dbOwnerB, dbNameB string, identB Identifier, merge MergeStrategy) (diffs com.Diffs, err error)

Diff returns the differences between two commits of two databases, or if the details on the second database are left empty, between two commits of the same database. You can also specify the merge strategy used for the generated SQL statements.

func (Connection) Indexes

func (c Connection) Indexes(dbOwner, dbName string, ident Identifier) (idx map[string]string, err error)

Indexes returns the list of indexes present in the database, along with the table they belong to

func (Connection) PrepareVals

func (c Connection) PrepareVals(dbOwner, dbName string, ident Identifier) (data url.Values)

PrepareVals creates a url.Values container holding the API key, database owner, name, and database identifier. The url.Values container is then used for the requests to

func (Connection) Query

func (c Connection) Query(dbOwner, dbName string, ident Identifier, blobBase64 bool, sql string) (out Results, err error)

Query runs a SQL query (SELECT only) on the chosen database, returning the results. The "blobBase64" boolean specifies whether BLOB data fields should be base64 encoded in the output, or just skipped using an empty string as a placeholder.

func (Connection) Tables

func (c Connection) Tables(dbOwner, dbName string, ident Identifier) (tbl []string, err error)

Tables returns the list of tables in the database

func (Connection) Views

func (c Connection) Views(dbOwner, dbName string, ident Identifier) (views []string, err error)

Views returns the list of views in the database

type Identifier

type Identifier struct {
	Branch   string `json:"branch"`
	CommitID string `json:"commit_id"`
	Release  string `json:"release"`
	Tag      string `json:"tag"`

Identifier holds information used to identify a specific commit, tag, release, or the head of a specific branch

type MergeStrategy

type MergeStrategy int

MergeStrategy specifies the type of SQL statements included in the diff results. The SQL statements can be used for merging databases and depending on whether and how you want to merge you should choose your merge strategy.

const (
	// NoMerge removes any SQL statements for merging from the diff results
	NoMerge MergeStrategy = iota

	// PreservePkMerge produces SQL statements which preserve the values of the primary key columns.
	// Executing these statements on the first database produces a database similar to the second.

	// NewPkMerge produces SQL statements which generate new values for the primary key columns when
	// executed. This avoids a couple of possible conflicts and allows merging more distant databases.

type ResultRow

type ResultRow struct {
	Fields []string

ResultRow is used for returning the results of a SQL query as a slice of strings

type Results

type Results struct {
	Rows []ResultRow

Results is used for returning the results of a SQL query as a slice of strings

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier