exqlite icon indicating copy to clipboard operation
exqlite copied to clipboard

drop db_connection

Open ruslandoga opened this issue 2 years ago • 4 comments

Since there is interest in moving db_connection to ecto_sqlite3, I thought I'd rebase https://github.com/ruslandoga/exqlite/pull/3 against the current master and resubmit.

Compared to https://github.com/ruslandoga/exqlite/pull/3 this PR is missing the quality of life improvements like the batched insert_all and fuller errors. I think those are quite needed for exqlite to be joyful to use on its own.

TODOs:

  • [ ] https://github.com/elixir-sqlite/exqlite/pull/271 functionality is "lost", what should be done about it?
  • [ ] ~~add multi_bind_step, insert_all, and prepare_insert_all or similar~~ actually now I'm thinking for the multi_ functions we can use Enumerable and Collectable protocols
:ok = Exqlite.execute(conn, "create table demo(a, b, c)")

Stream.repeatedly(fn -> [1, 2, 3] end)
|> Stream.take(100000)
|> Stream.chunk_every(500)
# internally calls something similar to multi_step but with an additional sqlite3_bind loop
|> Stream.into(Exqlite.stream(conn, "insert into demo(a, b, c) values(?, ?, ?)"))
|> Stream.run()

conn
# internally calls multi_step with 10 sqlite3_step loops per invocation
|> Exqlite.stream("select a, b, c from demo limit ?", [30], max_rows: 10)
|> Enum.into([])
  • [ ] add more info to %Exqlite.Error{}

ruslandoga avatar Dec 22 '23 08:12 ruslandoga

https://github.com/elixir-sqlite/exqlite/pull/271 functionality is "lost", what should be done about it?

Would it be useful to perhaps lift the callback definition to the same place after_connect is specified? https://github.com/elixir-ecto/db_connection/blob/fa5f705fa5d272ed28b64ee0954e4275c0260d36/lib/db_connection.ex#L118-L135 SQLite users can't be the only ones who would find a callback to fire before disconnect as useful.

warmwaffles avatar Dec 23 '23 14:12 warmwaffles

SQLite users can't be the only ones who would find a callback to fire before disconnect as useful.

My concern about such callbacks is that we can't ever rely on them running though (what if the whole node terminates), so I worry people may rely on it always executing. It probably makes more sense to setup a monitor process instead or similar.

josevalim avatar Apr 22 '24 12:04 josevalim

Sorry for disappearing without finishing the PR. I'm going to continue working on it later this week.

ruslandoga avatar Apr 29 '24 06:04 ruslandoga

@ruslandoga It's not a problem. I too, have had other priorities take over where I can't find time to carve out and think hard about this.

warmwaffles avatar Apr 29 '24 13:04 warmwaffles