daveaztig14
Hi,
I have built a simple elxiir app which receives request like:
curl "http://localhost:8085/pass" -H Content-Type: application/json; charset=utf-8’ -d '{"ticket": 1, "ver": "1", "os": "1"}'
and the output is:
ticket: 1, ver: 0.0.1.0_develop, os: ios
SQL Query = select * from database where ticket= 1 AND ver= 1 AND os= 1
(for the process or steps on how i did it please refer to How to use curl as input in elixir script? - #4 by NobbZ)
Anyway, I have a MySQL in remote host (sample ip: 10.10.11.11), a database named fortesting and a table named testingone.
My question is how connect my elixir app to my MySQL database in remote host (ip: 10.10.11.11)? and run the query select * from fortesting where ticket= 1 AND ver= 1 AND os= 1? using for example simple_server.exs and not the interactive elixir?
I’ve tried this: Executing raw SQL queries in Elixir | AmberBit Sp. z o. o. but did not work for me.
Any ideas, suggestions, links and help are welcome. Thank you.
Trending in Questions
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
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
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
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
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
wmnnd
It seems like you’re just getting started with Elixir, so you might want to check out Ecto which is used by most people in the Elixir community for working with SQL databases.
Take a look at the Getting Started guide:
NobbZ
What is the exact error you see? What behaviour did you observe, which did you expect?
daveaztig14
Hi @wmnnd,
Yes, just starting on Elixir, so far I know just the basics of Phoenix-Elixir-Ecto and I’m still researching and acquiring knowledge on the links and guides provided by hexdocs.
But in this case I just want to know if I can or if its possible execute raw query straight using elixir without using the mix ecto.create or without creating a repo.
Thanks and I’ll study the link you gave.
NobbZ
If you use
ecto, then you will need aRepo, as theRepois your wrapper around the connection pooling.Of course you can also use
postgrex(or any other driver) to directly do the low level dirty work to talk to your database…stefanluptak
Since you’re using MySQL, you probably want to use MyXQL.
GitHub: GitHub - elixir-ecto/myxql: MySQL 5.5+ driver for Elixir · GitHub
Docs: MyXQL — MyXQL v0.9.0
daveaztig14
Hi @NobbZ,
Actually what works for me is this:
And there I got the results of my query.
But what i want to do or to know if I can include the connection to the database and the query straight in an elixir file.
I tried this:
But nothing happens, still the reponse is:
ticket: 1, ver: 0.0.1.0_develop, os: ios
SQL Query = select * from database where ticket= 1 AND ver= 1 AND os= 1
NobbZ
send_respneeds to beiodata(simplified a string or an arbitrary deeply nested list of strings)Therefore I assume, that your actually crashes on your second
send_resp.joaoevangelista
It is possible to use raw drivers? Yes.
Suppose you want to use on a simple, not phoenix project
creating a project using
mix new my_app --supwill create the folders and the implementation of Application (the main entry point) which starts the supervision tree.Now the driver is just a “Worker” and we can start under the supervisor.
{:myxql, "~> 0.2.0"}to your dependencies and runmix deps.get, this is a new driver made for newer versions of mysqlMyApp.Application.start/2function we have thechildrenlist, there we will add the initialization for the driver.Note that we add a key
nameto the options with value:mydbthat is our identifier to use the same driver process in the application without the need to start/stop when a request comes.Now on your controller action or any where you need, even on
iex -S mix:Performing the query with
?on the string allows the driver do the sanatization, preventing SQL Injection.And thats it. For more infor on what you get from
MyXQL.query/3you can see the docs and the github repo