jordan0day

jordan0day

I have an application which I’m using Mariaex to query a MySQL db, but I’m not using Ecto. I’m curious what the proper way is to handle connection/instances of Mariaex for a long-running application? Under the hood, Mariaex uses DBConnection to create the connection and do all the connection pooling stuff, but I’m unsure if I’m supposed to just start one instance of Mariaex (via start_link) and hold on to that pid for the duration of the application (ultimately I’m sure I’d use a supervisor), or if I should be calling Mariaex.start_link/1 each time I want to perform a new query? If the latter, do I manually stop the pid returned by Mariaex.start_link/1 when the query has completed? Does DBConnection handle shutting it down?

I’ve looked through Mariaex, DBConnection, and Ecto’s codebases to try to understand how it’s handled in Ecto, but there’s a sufficient amount of abstraction and indirection that I haven’t really been able to tell how Ecto handles this.

I’d appreciate any advice anyone could provide on this.

** UPDATE **
Sorry, I guess I shouldn’t have posted this on a day when I was loaded up on cold medicine. I now see that I had forgotten to set the pool to DBConnection.Poolboy or DBConnection.Sojourn, (though in observer there was a DBConnection.Sojourn.Supervisor started, so I naively assumed sojourn was being used by default), and had confused myself about the connection behavior.

Showing Posts 1 to 6

nichochar

nichochar

Hi there,

I seem to have the exact same issue you do. Mainly when I use the Mariaex.transaction method, the connection seems to not function properly afterwards.

I believe I haven’t confired a pooling mechanism (poolboy or Sojourn). Where and how do you do this?

jordan0day

jordan0day OP

It’s in the options you pass to Mariaex.start_link/1, Mariaex.query/4, and again in the options passed to Mariaex.transaction/3. See mariaex/lib/mariaex.ex at master · xerions/mariaex · GitHub

Hope this helps!

nichochar

nichochar

Thanks this is exactly what I was looking for.

acrolink

acrolink

Is there any example of correct use of this library? Especially when it comes to opening and reusing conenctions (without Ecto)?

hubertlepicki

hubertlepicki

Hey, I had this blog post as draft for quite some time now, just published it for you:

is this helpful?

acrolink

acrolink

Absolutely, it was the very piece of code I was looking for :slight_smile: (I mean, using Supervisor and Poolboy). For my current little project, maximum 3 people would be interacting with the database at the same time, but I guess it is still better to set the connection up and let Poolboy handle the connections. Thank you.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews