Closed thdxr closed 3 years ago
@thdxr Sorry for the late reply. I've been meaning to answer this for a while, but I haven't had the time.
I've used AyeSQL mainly for querying stuff that usually would be too hard to query using just Ecto.
There was a project where we had some limititations and plain Ecto wouldn't be enough, so we used Ecto.Changeset
for inserts and updates mixing it with AyeSQL
instead of Ecto.Repo
.
In the end, Ecto is far superior for most use cases. However, mixing AyeSQL and Ecto might work when you need complex queries along with normal CRUD operations.
Wonder how do I do a bulk insert?
@dvv I usually mix it with Ecto.Multi and run each query in a transaction.
I see.
Just wanna explore how far can I reach without Ecto.
The following doesn't work with values = [[[1, "a"]]]]
:
insert into foo (col1, col2) values :values on conflict do nothing
-- ERROR 42601 (syntax_error) syntax error at or near "$1"
insert into foo (col1, col2) values (:values) on conflict do nothing
-- ERROR 42601 (syntax_error) INSERT has more target columns than expressions
Am I missing the way?
I was curious if you generally use
ayesql
alongside Ecto or if there's a good way to do inserts and updates usingayesql