Bun 正在参加 2020 年度 OSC 中国开源项目评选,请投票支持!
Bun 在 2020 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
投票让它出道
已投票
Bun 获得 2020 年度 OSC 中国开源项目评选「最佳人气项目」 !
Bun 获得 2020 年度 OSC 中国开源项目评选「最佳人气项目」「最积极运营项目」 !
Bun 获得 2020 年度 OSC 中国开源项目评选「最积极运营项目」 !

软件简介

Bun 是一个适用于 PostgreSQL、MySQL 和 SQLite 的简单且性能良好的 ORM。

Bun 是 Go 的一个 SQL-first 的数据库客户端。SQL-first 意味着大多数 SQL 查询可以自动编译为 Bun 表达式,而 Bun 表达式看起来和感觉就像 SQL 查询。

Bun 的目的是允许使用古老的SQL编写查询,并帮助将结果扫描成常见的 Go 类型:structs、maps、slices 和  columns。

主要特点是:

  • 适用于 PostgreSQL、 MySQL、 SQLite
  • 选择 map、struct、slice of maps/structs/vars
  • 批量插入
  • 使用公用表表达式批量更新
  • 批量删除
  • Fixtures
  • 迁移
  • 软删除
package main

import (
	"context"
	"database/sql"
	"fmt"

	"github.com/uptrace/bun"
	"github.com/uptrace/bun/dialect/sqlitedialect"
	"github.com/uptrace/bun/driver/sqliteshim"
	"github.com/uptrace/bun/extra/bundebug"
)

func main() {
	ctx := context.Background()

	// Open an in-memory SQLite database.
	sqlite, err := sql.Open(sqliteshim.ShimName, "file::memory:?cache=shared")
	if err != nil {
		panic(err)
	}

	// Create a Bun db on top of it.
	db := bun.NewDB(sqlite, sqlitedialect.New())

	// Print all queries to stdout.
	db.AddQueryHook(bundebug.NewQueryHook(bundebug.WithVerbose()))

	var rnd int64

	// Select a random number.
	if err := db.NewSelect().ColumnExpr("random()").Scan(ctx, &rnd); err != nil {
		panic(err)
	}

	fmt.Println(rnd)
}
展开阅读全文

代码

评论 (0)

加载中
更多评论
暂无内容
2020/12/05 18:56

python制作“小兔子和Bun"小游戏

**说明** python版本:3.5.4 pygame版本:1.9.3(pip安装即可) **愉快地开始** **Step1:你好,兔子** ![](https://oscimg.oschina.net/oscnet/up-5d3d39d08f84e0345c590cb674cfa2f9a47.png) 效果: ![](https://oscimg.oschina.net/oscnet/up-11d77a93e04ab65a75be386f11516a7ca8b.png) **Step2:添加背景** 首先载入所需的图片;其次依次通过x和y进行循环,并且根据循环里x和y的值来画上草的效果;接下来的几行就是在屏幕上画...

0
0
发表了博客
2020/01/09 19:02

揭秘2019年Python这一款“小兔子和Bun”游戏,附赠游戏源码文件

#### **导语** 这又将是一个不定期更新的系列~~~ 本系列主要将使用到python的pygame模块来教大家制作一些小游戏,每期制作一个。最后都会打包成.exe文件分享给大家~~~ **So,对于只想玩小游戏的小伙伴来说,只需要下载相关文件就好啦~~~** 至于pygame的开发文档,暂时没有归入整理计划,来日方长,英文不好的同学只能先看网上中文的资料将就下了~~~ #### **准备工作:安装Python** python版本:3.5.4 pygame版本:1.9.3(pip安装...

0
0
发表了博客
2018/05/02 20:34

[T-ARA N4/二段横踢][Can We Love]

歌词来源:http://music.163.com/#/song?id=26310867 Can We Love Can We Love [Can We Love Can We Love] Can We Love Can We Love [Can We Love Can We Love] 꾸벅 허리를 숙이며 나에게 인사 [ggu-beo Keo-li-leul su-gi-myeo na-e-ge in-sa] 첫만남에 벌써 그 남자가 빛나 [Ceon-man-na-me beol-sseo keu nam-ja-ga pin-na] 신사같음에도 뭔가 와일드해 [xin-sa-ga-Teu-me-do mwon-ga wa-il-deu-ae] 동갑임에도 뭔가 나이스...

0
0
发表了博客
2014/12/25 15:48

Flat iron within a exceptionally boho

The wedding ceremony day can be this type of an extraordinary moment irrespective of whether anyone are definitely the one that will be getting married and / or you are the actual bridesmaid for ones companion. They require perfect hair styles and you can get them through a selection of flat iron brands essentially the most antique for hairstyles which can be carrying out typically the circular...

0
0
发表了博客
2014/12/25 15:51

Babyliss pro miracurl Chic 50 percent " up "

The wedding working day is without a doubt these a special time whether or not you will might possibly be the an individual that is certainly marriage or even you might be this maid-matron of honour for your closest friend. Needed fantastic hairdos and you could buy them by using numerous one of ghd flat iron the most typical regarding hair styling that happen to be engaging in the actual aroun...

0
0
发表了博客
2019/03/06 21:25

buns~~~一个简单的背包问题

戳我看原题 题目 C. Buns time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lavrenty, a baker, is going to make several buns with stuffings and sell them. Lavrenty has n grams of dough as well as m different stuffing types. The stuffing types are numerated from 1 to m. Lavrenty knows that he has ai grams left of the i-th stuffing. It ta...

0
0
发表了博客
2018/12/09 00:17

AtCoder Beginner Contest 115 题解

题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit : 1024MB Score : 100 points Problem Statement In some other world, today is December D-th. Write a program that prints Christmas if D=25, Christmas Eve if D=24, Christmas Eve Eve if D=23 and Christmas Eve Eve Eve if D=22. Constraints 22≤D≤25 D is an integer. Input Input is given from S...

0
0
发表了博客
2014/12/23 15:13

Flat iron upwards best

There are numerous situations for you to can be anxious precisely why we know have locks who are thus challenging to fund in addition to likely to obtain frizzy. Having said that, if you ever decide the perfect Finnish start look of your hair and see this amazing things that delivers to flat iron brands the tresses while they can be curly. This is certainly a remarkably simple and easy hair do ...

0
0
发表了博客
2014/12/23 15:08

Cheap flat iron​ flag the idea

There are several situations for you to might possibly be anxious precisely why we know do you have locks who are thus challenging to handle in addition to likely to secure frizzy. Having said that, if you ever decide the perfect Finnish start look of your hair and see this amazing things that delivers to the tresses while they can be curly. This is certainly a remarkably simple and easy hair d...

0
0
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
暂无内容
0 评论
2 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部