SQLBoiler ORM,如何执行不带绑定的原始查询?

huangapple go评论88阅读模式
英文:

SQLBoiler ORM, how to execute raw query without binding?

问题

我正在尝试使用这个ORM生成器:https://github.com/vattle/sqlboiler,并且我正在尝试使用boil.SQL来执行原始查询,我在他们的文档中看到了这个方法。但是当我使用boil.SQL().时,我发现唯一可用的方法是Bind。有没有办法在不绑定到对象的情况下执行查询?因为我不需要任何返回结果。

谢谢。

英文:

I'm trying this ORM generator here https://github.com/vattle/sqlboiler

and I'm trying to execute a raw query using boil.SQL which I can see in their documentation. But when I do boil.SQL()., I see that the only methods available are Bind. Is there a way I can execute the query without binding to an object? Because I do not need any results back.

Thanks.

答案1

得分: 1

boil.SQL() 返回一个 *boil.Query。如果你不关心结果,你可以将其传递给 boil.ExecQuery()

q := boil.SQL("execute foo()")
_, err := boil.ExecQuery(q)

https://godoc.org/github.com/vattle/sqlboiler/boil#ExecQuery

英文:

boil.SQL() returns a *boil.Query. You can pass this into boil.ExecQuery() if you don't care about the results.

q := boil.SQL("execute foo()")
_, err := boil.ExecQuery(q)

https://godoc.org/github.com/vattle/sqlboiler/boil#ExecQuery

huangapple
  • 本文由 发表于 2016年9月6日 01:23:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/39335248.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定