<p>I use the <a href="https://github.com/jackc/pgx" rel="nofollow">https://github.com/jackc/pgx</a> library to access Postgresql. I was curious if anyone has written any ORM or helpers for this?</p>
<hr/>**评论:**<br/><br/>aarondl: <pre><p>Although we've never tested it officially, there should be no problems in using <a href="https://github.com/vattle/sqlboiler" rel="nofollow">https://github.com/vattle/sqlboiler</a> - although it's a newer ORM it's got a fairly unique approach than other ORM-like things out there.</p>
<p>On the surface the only problem would be you'd need a very small wrapper to expose pgx's database connection as an boil.Executor because it's Exec() method doesn't use sql.Result interface. I can help you do this if you need :)</p></pre>tvmaly: <pre><p>I will take a look at it. I wanted something a bit simple, almost more like a helper than an ORM to handle the Scan part so I did not have to type as much. </p>
<p>I really was hoping to find something that would let me keep my struct members as regular types string, int64, bool etc. </p></pre>aarondl: <pre><p>There's nothing in the ecosystem that will let you keep your types simply because Go does not allow int, string, etc to be null. In sqlboiler if you have no nullable columns, your types will all be regular :)</p></pre>bketelsen: <pre><p>github.com/markbates/pop
github.com/jmoiron/sqlx</p></pre>PaluMacil: <pre><p>If you're strong with SQL, this really does appear to be the way to go (no pun intended). So far I've been looking at BoltDb, but for SQL, I'd use slqx.</p></pre>tvmaly: <pre><p>I have done a lot with BoltDB, and I find it is super useful. Where it really shined for me was with an autocomplete for cities around the world. When I initially setup my service, I used an in memory trie. It worked great on my local machine with tons of memory, but when I deployed it to a VPS, I quickly ran into the memory limits of that machine. When I switched to BoltDB it ran without issue</p></pre>tvmaly: <pre><p>sqlx might be exactly what I need.</p>
<p>I just came across <a href="https://upper.io/db.v2/" rel="nofollow">https://upper.io/db.v2/</a> but it only supports github.com/lib/pq</p></pre>tvmaly: <pre><p>I just had another question on sqlx, there is a stated requirement "if you have null fields and use SELECT <em>, you must use sql.Null</em> in your struct" Is there a cleaner way to work around this ?</p></pre>woodenpants: <pre><p>Check out gorm. Very easy to use </p></pre>aarondl: <pre><p>Gorm gets weird around the edges. Considering you need extra struct fields and magic struct tags to do relationships. It's design starts to show it's holes the more of API surface area you touch. It's query building and struct binding also performs quite bad relative things like gorp or sqlboiler.</p></pre>phacus: <pre><p>Seconded that.</p>
<p>I've used in one project and it's very easy to use, also has a good documentation.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传