top

Package db (or upper-db) provides a common interface to work with different data sources using adapters that wrap mature database drivers.

The main purpose of upper-db is to abstract common database operations and encourage users perform advanced operations directly using the underlying driver. upper-db supports the MySQL, PostgreSQL, SQLite and QL databases and provides partial support (CRUD, no transactions) for MongoDB.

go get upper.io/db.v2

Usage

package main

import (
	"log"

	"upper.io/db.v2/postgresql" // Imports the postgresql adapter.
)

var settings = postgresql.ConnectionURL{
	Database: `booktown`,
	Host:     `demo.upper.io`,
	User:     `demouser`,
	Password: `demop4ss`,
}

// Book represents a book.
type Book struct {
	ID        uint   `db:"id"`
	Title     string `db:"title"`
	AuthorID  uint   `db:"author_id"`
	SubjectID uint   `db:"subject_id"`
}

func main() {
	sess, err := postgresql.Open(settings)
	if err != nil {
		log.Fatal(err)
	}
	defer sess.Close()

	var books []Book
	if err := sess.Collection("books").Find().OrderBy("title").All(&books); err != nil {
		log.Fatal(err)
	}

	log.Println("Books:")
	for _, book := range books {
		log.Printf("%q (ID: %d)\n", book.Title, book.ID)
	}
}

See more usage examples and documentation for users at https://upper.io/db.v2.

Imported by 48 package(s)

  1. github.com/0x434D53/db/internal/logger
  2. github.com/0x434D53/db/internal/sqladapter
  3. github.com/0x434D53/db/mongo
  4. github.com/0x434D53/db/mysql
  5. github.com/0x434D53/db/postgresql
  6. github.com/0x434D53/db/ql
  7. github.com/0x434D53/db/sqlite
  8. github.com/ArturoVM/db/internal/logger
  9. github.com/ArturoVM/db/internal/sqladapter
  10. github.com/ArturoVM/db/mongo
  11. github.com/ArturoVM/db/mysql
  12. github.com/ArturoVM/db/postgresql
  13. github.com/ArturoVM/db/ql
  14. github.com/ArturoVM/db/sqlite
  15. github.com/gophergala2016/FriendzoneTeam/services
  16. github.com/malfunkt/hyperfox
  17. github.com/philipgiuliani/rustplanner
  18. github.com/philipgiuliani/rustplanner/controllers
  19. github.com/se77en/db/internal/logger
  20. github.com/se77en/db/internal/sqladapter
  21. github.com/se77en/db/mongo
  22. github.com/se77en/db/mysql
  23. github.com/se77en/db/postgresql
  24. github.com/se77en/db/ql
  25. github.com/se77en/db/sqlbuilder
  26. github.com/se77en/db/sqlite
  27. github.com/upper/bond
  28. github.com/upper/db/mongo
  29. github.com/upper/db/mysql
  30. github.com/upper/db/postgresql
  31. github.com/upper/db/ql
  32. github.com/upper/db/sqlite
  33. github.com/xiam/shooter-server
  34. upper.io/bond
  35. upper.io/db.v2/builder
  36. upper.io/db.v2/internal/adapter
  37. upper.io/db.v2/internal/debug
  38. upper.io/db.v2/internal/logger
  39. upper.io/db.v2/internal/sqladapter
  40. upper.io/db.v2/internal/sqlutil/result
  41. upper.io/db.v2/internal/sqlutil/tx
  42. upper.io/db.v2/lib/sqlbuilder
  43. upper.io/db.v2/mongo
  44. upper.io/db.v2/mysql
  45. upper.io/db.v2/postgresql
  46. upper.io/db.v2/ql
  47. upper.io/db.v2/sqlbuilder
  48. upper.io/db.v2/sqlite

Imported only in test by 6 package(s)

  1. github.com/0x434D53/db
  2. github.com/ArturoVM/db
  3. github.com/fanyang01/db
  4. github.com/se77en/db
  5. github.com/upper/db
  6. github.com/xiam/db

Test imports 7 package(s)

  1. gopkg.in/mgo.v2/bson
  2. upper.io/db.v2/mysql
  3. upper.io/db.v2/ql
  4. upper.io/db.v2/sqlite
  5. gopkg.in/mgo.v2
  6. upper.io/db.v2/mongo
  7. upper.io/db.v2/postgresql