英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论