update
This commit is contained in:
parent
470b213e29
commit
f85ba44ec0
@ -2,8 +2,8 @@ Comparing Go GORM and SQLX
|
|||||||
##########################
|
##########################
|
||||||
:author: tyrel
|
:author: tyrel
|
||||||
:category: Tech
|
:category: Tech
|
||||||
:tags: go, sql, python
|
:tags: go, sql, python, gorm, sqlx
|
||||||
:status: draft
|
:status: published
|
||||||
|
|
||||||
Django ORM - My History
|
Django ORM - My History
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -156,6 +156,7 @@ This will return a slice of Albums - but if you notice on the second line, you h
|
|||||||
A little bit more in control of how things happen, with a ``SELECT * ...`` vs the gorm ``DB.Find`` style.
|
A little bit more in control of how things happen, with a ``SELECT * ...`` vs the gorm ``DB.Find`` style.
|
||||||
|
|
||||||
To me this feels more like using ``pymysql``, in fact its a very similar process.
|
To me this feels more like using ``pymysql``, in fact its a very similar process.
|
||||||
|
(SEE NOTE BELOW)
|
||||||
You use the ``service.connection.Get`` and pass in what you want the output bound to, the string query, and any parameters.
|
You use the ``service.connection.Get`` and pass in what you want the output bound to, the string query, and any parameters.
|
||||||
This feels kind of backwards to me - I'd much rather have the order be: query, bound, parameters, but thats what they decided for their order.
|
This feels kind of backwards to me - I'd much rather have the order be: query, bound, parameters, but thats what they decided for their order.
|
||||||
|
|
||||||
@ -177,3 +178,12 @@ Repositories
|
|||||||
|
|
||||||
* `Go, Gin, Gorm <https://gitea.tyrel.dev/tyrel/go-webservice-gin>`_
|
* `Go, Gin, Gorm <https://gitea.tyrel.dev/tyrel/go-webservice-gin>`_
|
||||||
* `Go, Gin, sqlx <https://gitea.tyrel.dev/tyrel/go-webservice-gin-sqlx>`_
|
* `Go, Gin, sqlx <https://gitea.tyrel.dev/tyrel/go-webservice-gin-sqlx>`_
|
||||||
|
|
||||||
|
Notes
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
I sent this blog post to my friend `Andrey <https://shazow.net/>`_ and he mentioned that I was incorrect with my comparision of sqlx to pymysql.
|
||||||
|
To put it in a python metaphor, "sqlx is like using urllib3, gorm is like using something that generates a bunch of requests code for you."
|
||||||
|
Sqlx is more akin to `SqlAlchemy core <https://docs.sqlalchemy.org/en/14/core/>`_ vs using `SqlAlchemy orm <https://docs.sqlalchemy.org/en/14/orm/>`_.
|
||||||
|
As the sort of equivalent to ``pymysql`` in Go is ``database/sql`` from the stdlib.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user