marcojulian
Looking for a Change Data Capture (CDC) lib for MySQL
My Elixir application needs to connect with a MySQL database and listen for insert and updates in certain tables, does anyone know about a library that makes this easier? I would use WalEx or Cainophile but they are intended for PostgreSQL DBs.
Marked As Solved
joerichsen
Hi
You could use Port — Elixir v1.16.3 with the stdout option of https://maxwells-daemon.io/
I have this proof of concept code that might get you started
defmodule MaxwellListener do
use GenServer
# Adjust the command to include the full executable path if necessary
@command "maxwell"
@args [
"--user='maxwell'",
"--password='XXXXXX'",
"--host='127.0.0.1'",
"--filter='exclude: *.*, include: holdsport.users, include: holdsport.teams_users'",
"--producer=stdout"
]
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, :ok, opts)
end
def init(:ok) do
command_with_args = Enum.join([@command | @args], " ")
options = [:binary, :exit_status]
port = Port.open({:spawn, command_with_args}, options)
{:ok, %{port: port}}
end
def handle_info({port, {:data, data}}, state) do
process_output(data)
{:noreply, state}
end
def handle_info({:EXIT, _port, _reason}, state) do
# Handle port exit
{:stop, :normal, state}
end
defp process_output(data) do
data
|> String.trim_trailing()
|> Jason.decode!(keys: :atoms)
|> handle()
end
defp handle(%{table: "teams_users", data: %{users_id: user_id}}) do
IO.inspect(user_id, label: "User ID")
end
defp handle(d) do
IO.inspect(d, limit: :infinity)
end
end
1
Popular in Questions
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
Other popular topics
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New







