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?
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.
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.