Megatomix

Megatomix

Backend with pure elixir (direct SQL in DataBase) without frameworks possible?

Is it possible to program backend with pure elixir (direct SQL in BD) without frameworks? What are the challenges or problems?

Most Liked

lpil

lpil

Creator of Gleam

SQL query builders such as Ecto are just one approach to querying a database, other options are available, and in some other ecosystems these options more popular.

Personally I am a fan of writing plain SQL and have written a small library to make this a bit more convenient in Elixir. GitHub - lpil/yesql: An Elixir library for using SQL.

lpil

lpil

Creator of Gleam

Hi Megatomic! Welcome to the forum!

There’s no need for any specific library or framework to make a backend in Elixir, it just means that you have to make more decisions about what conventions and patterns to employ, and you may need to implement some functionality that the frameworks might otherwise offer.

At my previous workplace we had Elixir services that didn’t use the Phoenix framework or the Plug webserver abstraction, instead we just used the Elli web server (which has a very simple interface). We could have also done the same with Cowboy if desired.
The Raxx web server would have also been a good fit, we went for Elli as Raxx didn’t have middleware at the time.

The service that had a postgres database used Ecto, though if writing it again we might have instead opted to use the Postgrex library directly as we didn’t find Ecto offered much in that specific use-case. Our tech stack was quite diverse so we found that keeping things as simple as possible and using as few libraries and macros as possible made maintenance and on-boarding easier.

So yes, it is possible to implement a backend in Elixir without frameworks.

What’s a BD? :slight_smile:

Megatomix

Megatomix

Sorry: a failed act at writing
BD = DB
BD in portuguese, DB in english (DataBase)

AstonJ

AstonJ

If you are a beginner in development I would highly recommend using a framework like Phoenix - it makes a lot of sensible choices for you and so will save you a lot of headache - saving you from having to research all the different paths/approaches etc.

I would ask, why not use a framework? If you don’t have any pressing reasons not to use a framework, I would say use one :023:

sribe

sribe

??? You have SQL, which has joins, aggregations, etc. Not every project needs an ORM to simulate “object” coming from the db. Some (think utilities) work perfectly well sending queries to the db and getting back an array of maps.

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
freewebwithme
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
ashish173
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
shahryarjb
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
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
Fl4m3Ph03n1x
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
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New

We're in Beta

About us Mission Statement