技术控

    今日:10| 主题:49195
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] upper.io - database access

[复制链接]

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
upper.io/db.v2         

  The    upper.io/db.v2package for    Gois    notan ORM, it's just a productive data access layer for Go which provides a common interface to work with different data sources such as    PostgreSQL,    MySQL,    SQLite,    QLand    MongoDB.  
  1. go get upper.io/db.v2
复制代码
User documentation

  This is the source code repository, see examples and documentation at    upper.io/db.v2.  
  Demo

  You can run the following example on our    playground:  
  1. package main
  2. import (
  3.     "log"
  4.     "upper.io/db.v2/postgresql"
  5. )
  6. var settings = postgresql.ConnectionURL{
  7.     Host:     "demo.upper.io",
  8.     Database: "booktown",
  9.     User:     "demouser",
  10.     Password: "demop4ss",
  11. }
  12. type Book struct {
  13.     ID        int    `db:"id"`
  14.     Title     string `db:"title"`
  15.     AuthorID  int    `db:"author_id"`
  16.     SubjectID int    `db:"subject_id"`
  17. }
  18. func main() {
  19.     sess, err := postgresql.Open(settings)
  20.     if err != nil {
  21.         log.Fatalf("db.Open(): %q\n", err)
  22.     }
  23.     defer sess.Close()
  24.     var books []Book
  25.     err = sess.Collection("books").Find().All(&books)
  26.     if err != nil {
  27.         log.Fatalf("Find(): %q\n", err)
  28.     }
  29.     for i, book := range books {
  30.         log.Printf("Book %d: %#v\n", i, book)
  31.     }
  32. }
复制代码
Or you can also run it locally from the    _examplesdirectory:  
  1. go run _examples/booktown-books/main.go
  2. 2016/08/10 08:42:48 "The Shining" (ID: 7808)
  3. 2016/08/10 08:42:48 "Dune" (ID: 4513)
  4. 2016/08/10 08:42:48 "2001: A Space Odyssey" (ID: 4267)
  5. 2016/08/10 08:42:48 "The Cat in the Hat" (ID: 1608)
  6. 2016/08/10 08:42:48 "Bartholomew and the Oobleck" (ID: 1590)
  7. 2016/08/10 08:42:48 "Franklin in the Dark" (ID: 25908)
  8. 2016/08/10 08:42:48 "Goodnight Moon" (ID: 1501)
  9. 2016/08/10 08:42:48 "Little Women" (ID: 190)
  10. 2016/08/10 08:42:48 "The Velveteen Rabbit" (ID: 1234)
  11. 2016/08/10 08:42:48 "Dynamic Anatomy" (ID: 2038)
  12. 2016/08/10 08:42:48 "The Tell-Tale Heart" (ID: 156)
  13. 2016/08/10 08:42:48 "Programming Python" (ID: 41473)
  14. 2016/08/10 08:42:48 "Learning Python" (ID: 41477)
  15. 2016/08/10 08:42:48 "Perl Cookbook" (ID: 41478)
  16. 2016/08/10 08:42:48 "Practical PostgreSQL" (ID: 41472)
复制代码
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

  
       
  • José Carlos Nieto <      [email protected]>   
  • Peter Kieltyka <      [email protected]>   
  • Maciej Lisiewski <      [email protected]>   
  • Max Hawkins <      [email protected]>   
  • Paul Xue <      [email protected]>   
  • Kevin Darlington <      [email protected]>   
  • Lars Buitinck <      [email protected]>   
  • icattlecoder <      [email protected]>   
  • Aaron <      [email protected]>   
  • Hiram J. Pérez <      [email protected]>   
  • Julien Schmidt <      [email protected]>   
  • Max Hawkins <      [email protected]>   
  • Piotr "Orange" Zduniak <      [email protected]>   
  • achun <      [email protected]>   
  • rjmcguire <      [email protected]>   
  • wei2912 <      [email protected]>  
友荐云推荐




上一篇:Google CCTZ binding for Node.JS
下一篇:Node.js update makes JavaScript VMs future-proof
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表