Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper way to handle mariaex/dbconnection process? #149

Closed
jordan0day opened this issue Nov 14, 2016 · 3 comments
Closed

Proper way to handle mariaex/dbconnection process? #149

jordan0day opened this issue Nov 14, 2016 · 3 comments

Comments

@jordan0day
Copy link
Contributor

I've asked this question over on elixirforum but I thought I might check here as well. I'm just curious what the correct pattern for handling Mariaex processes is for a long-running application, not using Ecto.

Should I start up the Mariaex process (via Mariaex.start_link/1) and then hold on to that pid, using it for all subsequent queries? Or should I stop that process as soon as I'm done with a particular query, and spin up a new process when I need to make another query later on? I know under the covers using DBConnection all the connection pooling stuff should be handled for me, but I tried to dig through Ecto's codebase to see how it was done there and came up more confused than I was when I started.

@jordan0day
Copy link
Contributor Author

Sorry, loaded up on cold medicine today and wasn't thinking clearly nor parsing the existing code clearly.

@acrolink
Copy link

@jordan0day Would you mind what you have done eventually? Open and close connections, or using some global pid to do subsequent queries?

@jordan0day
Copy link
Contributor Author

I ended up using a global pid running under a supervisor. For anyone else looking at this, this blog post (linked in the elixirforum thread) is very similar to how I'm using it (scroll down to 'For mariaex, we need to...'):
https://www.amberbit.com/blog/2018/6/12/executing_raw_sql_queries_in_elixir/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants