Managing DB operation in a phoenix projects without Ecto

I am building a Phoenix project. The DB I am using doesn’t have mature enough Ecto Adapter available. What would be the best practice for handling DB operations in a Phoenix project without Ecto?

Visit DGraph for DB details

The concern arises from the fact that Ecto provides a ease of usage and connection pooling. Without Ecto in Phoenix, we will have to take care of these things manually. It seems odd to separate Ecto and Phoenix.

There’s probably a library for this database. I’ve seen it being mentioned on the forum. So you could probably use it instead of ecto.

Here it is Please add DGraph DB to Elixir - support one more graph db

Yes there is a library. Should I put all the functions related to DB operations inside the Controller-s?

I am concerned that this might open too many db connection.

Should I put all the functions related to DB operations inside the Controller-s?

That depends on your app architecture. I would put them someplace else for easier testing, like into what’s currently called a “context” in phoenix.

I am concerned that this might open too many db connection.

I think one of the libraries uses poolboy, so it would probably check out a connection from a pool rather than create them for each operation. And all the tcp connections to the database would probably be created during the library’s app startup/initialization.

1 Like