1
0
mirror of https://github.com/webx-top/db synced 2021-12-20 05:52:40 +00:00
Go to file
2021-12-15 13:25:01 +08:00
_examples/booktown-books added event:read 2020-04-02 15:18:51 +08:00
_tools update 2021-05-22 15:43:42 +08:00
clickhouse clickhouse: clean & fix 2021-05-23 13:44:14 +08:00
cmd/dbgenerator update 2021-11-29 17:56:21 +08:00
internal fix 2021-12-15 13:25:01 +08:00
lib update 2021-12-01 11:42:39 +08:00
mongo update 2021-10-27 14:30:58 +08:00
mssql 更新到v3.7.1 2020-06-26 22:33:48 +08:00
mysql update 2021-08-15 10:13:41 +08:00
postgresql update 2021-02-22 18:42:26 +08:00
ql 更新到v3.7.1 2020-06-26 22:33:48 +08:00
sqlite update 2021-11-15 17:38:37 +08:00
tests improved 2021-02-22 11:05:39 +08:00
.gitignore update 2021-11-15 17:38:37 +08:00
CHANGELOG.md added event:read 2020-04-02 15:18:51 +08:00
collection.go added event:read 2020-04-02 15:18:51 +08:00
comparison.go added event:read 2020-04-02 15:18:51 +08:00
compound.go update-vendor 2021-10-07 20:16:35 +08:00
cond_test.go added event:read 2020-04-02 15:18:51 +08:00
cond.go added event:read 2020-04-02 15:18:51 +08:00
constraint.go added event:read 2020-04-02 15:18:51 +08:00
database.go update 2021-07-13 15:52:51 +08:00
db_ex.go update 2021-11-30 14:23:57 +08:00
db.go added event:read 2020-04-02 15:18:51 +08:00
env.go added event:read 2020-04-02 15:18:51 +08:00
errors.go update 2021-07-31 13:23:20 +08:00
function_test.go 更新到v3.7.1 2020-06-26 22:33:48 +08:00
function.go 更新到v3.7.1 2020-06-26 22:33:48 +08:00
go.mod update 2021-11-29 17:41:06 +08:00
go.sum update 2021-11-29 17:41:06 +08:00
intersection.go added event:read 2020-04-02 15:18:51 +08:00
logger_test.go fix 2020-04-06 19:01:07 +08:00
logger.go update 2021-11-02 12:19:28 +08:00
Makefile added event:read 2020-04-02 15:18:51 +08:00
marshal.go added event:read 2020-04-02 15:18:51 +08:00
operators.go added event:read 2020-04-02 15:18:51 +08:00
raw.go 更新到v3.7.1 2020-06-26 22:33:48 +08:00
README.md update 2021-05-22 15:43:42 +08:00
result.go fix-typo 2021-03-07 13:12:11 +08:00
settings.go update 2021-11-02 11:50:48 +08:00
tx.go added event:read 2020-04-02 15:18:51 +08:00
union.go added event:read 2020-04-02 15:18:51 +08:00
url.go added event:read 2020-04-02 15:18:51 +08:00
wrapper.go update 2021-07-31 13:23:20 +08:00

webx-top/db

Forked from upper/db

本仓库新增功能

  1. 支持表前缀
  2. 支持ForceIndex查询
  3. 支持关联查询感谢gosql提供灵感查看用法
  4. 新增lib/factory
  5. 增加MySQL表结构体生成工具安装命令go install github.com/webx-top/db/cmd/dbgenerator,使用命令dbgenerator -h查看用法)
  6. 其它改进

原始文档

Cases

upper.io/db.v3 Build Status GoDoc

The upper.io/db.v3 package for Go is a productive data access layer for Go that provides a common interface to work with different data sources such as PostgreSQL, MySQL, SQLite, MSSQL, QL and MongoDB.

go get upper.io/db.v3

The tour

screen shot 2017-05-01 at 19 23 22

Take the tour to see real live examples in your browser.

Live demos

You can run the following example on our playground:

package main

import (
	"log"

	"github.com/webx-top/db/postgresql"
)

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

type Book struct {
	ID        int    `db:"id"`
	Title     string `db:"title"`
	AuthorID  int    `db:"author_id"`
	SubjectID int    `db:"subject_id"`
}

func main() {
	sess, err := postgresql.Open(settings)
	if err != nil {
		log.Fatalf("db.Open(): %q\n", err)
	}
	defer sess.Close()

	var books []Book
	err = sess.Collection("books").Find().All(&books)
	if err != nil {
		log.Fatalf("Find(): %q\n", err)
	}

	for i, book := range books {
		log.Printf("Book %d: %#v\n", i, book)
	}
}

Or you can also run it locally from the _examples directory:

go run _examples/booktown-books/main.go
2016/08/10 08:42:48 "The Shining" (ID: 7808)
2016/08/10 08:42:48 "Dune" (ID: 4513)
2016/08/10 08:42:48 "2001: A Space Odyssey" (ID: 4267)
2016/08/10 08:42:48 "The Cat in the Hat" (ID: 1608)
2016/08/10 08:42:48 "Bartholomew and the Oobleck" (ID: 1590)
2016/08/10 08:42:48 "Franklin in the Dark" (ID: 25908)
2016/08/10 08:42:48 "Goodnight Moon" (ID: 1501)
2016/08/10 08:42:48 "Little Women" (ID: 190)
2016/08/10 08:42:48 "The Velveteen Rabbit" (ID: 1234)
2016/08/10 08:42:48 "Dynamic Anatomy" (ID: 2038)
2016/08/10 08:42:48 "The Tell-Tale Heart" (ID: 156)
2016/08/10 08:42:48 "Programming Python" (ID: 41473)
2016/08/10 08:42:48 "Learning Python" (ID: 41477)
2016/08/10 08:42:48 "Perl Cookbook" (ID: 41478)
2016/08/10 08:42:48 "Practical PostgreSQL" (ID: 41472)

Documentation for users

This is the source code repository, check out our release notes and see examples and documentation at upper.io/db.v3.

Changelog

See CHANGELOG.md.

License

This project is licensed under the terms of the MIT License.

Copyright (c) 2012-present The upper.io/db authors. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors and contributors