Seeking a ORM or better way to work with jackc/pgx for postgresql

xuanbao · · 803 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<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&#39;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&#39;s a newer ORM it&#39;s got a fairly unique approach than other ORM-like things out there.</p> <p>On the surface the only problem would be you&#39;d need a very small wrapper to expose pgx&#39;s database connection as an boil.Executor because it&#39;s Exec() method doesn&#39;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&#39;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&#39;re strong with SQL, this really does appear to be the way to go (no pun intended). So far I&#39;ve been looking at BoltDb, but for SQL, I&#39;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 &#34;if you have null fields and use SELECT <em>, you must use sql.Null</em> in your struct&#34; 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&#39;s design starts to show it&#39;s holes the more of API surface area you touch. It&#39;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&#39;ve used in one project and it&#39;s very easy to use, also has a good documentation.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

803 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传