vonH
What are my options for simple and direct SQL database access in Elixir?
I have a simple relational database structure I want to do simple CRUD operations on.
Open the database, create a new record, open a result set, scan for those I want, update or delete them. If anyone has used the ADODB in PHP they will understand what I want. I have taken a look at Ecto, but what I have seen seems too complicated for what I need, or it may because the examples don’t focus on my immediate use case.
I have seen something that seems to fit the bill - GitHub - robconery/moebius: A functional query tool for Elixir · GitHub - which seems to fit the bill but only works for Postgres. If there is something similar which deals with multiple databases that will be better, as Postgres is overkill for what I want to accomplish. Something like moebius that handles SQLite will be better.
Is there some guide to ecto that teaches how to do the simple actions above on an existing database? It is a small database which is only expected to handle a few 1000 records, so if I am using ecto I am hoping ecto can inspect the schema and create its own schema code from it, like Django’s South.
Most Liked
karmajunkie
Per the Ecto docs, you can use the Ecto.Adapter.SQL module to run SQL directly:
iex> Ecto.Adapters.SQL.query(MyRepo, "SELECT $1::integer + $2", [40, 2])
{:ok, %{rows: [{42}], num_rows: 1}}
In addition to moebius, there’s also this project that looks interesting to me: GitHub - fazibear/defql: Create elixir functions with SQL as a body. · GitHub. I’ve gone so far as to install it but I’m not using it for anything so I can’t give much of a review of it.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









