hugoestr

hugoestr

What is the standard way to work with existing databases and tables in Ecto in 2025?

I need to communicate to an existing database. I would like to have a schema for the table that I will query. Do I need to create the schema by hand? Or is there a standard tool to do this?

My searches show old libraries that are officially not supported. Other suggestions that encourages manually writing the schema seem pretty old. If manually doing it is the way, I am fine with that. I am trying to double check that is the standard solution for this problem

Marked As Solved

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Back in the day I hand wrote a script to turn a pg_dump into a bunch of ecto files. It worked but that was 8+ years ago so I don’t think I have it anymore. Today though? I’d chuck a schema only pg_dump at an LLM and then review it afterward. Text transformations are its bread and butter.

Also Liked

outlog

outlog

there are the old ones plsm comes to mind, and then LLM - also worth noting ash can generate resources from existing DB ash_postgres/documentation/tutorials/set-up-with-existing-database.md at main · ash-project/ash_postgres · GitHub - even if you don’t need ash it might generate structured data for you (or an LLM)..

dimitarvp

dimitarvp

You might also try with dynamic introspection if you ever need it: Endo — Endo v0.1.24

Not sure the library is very actively maintained anymore but if it is feature-complete then that does not matter.

There is also this: GitHub - cogini/ecto_extract_migrations: Elixir library to generate Ecto migrations from a PostgreSQL schema SQL file. Uses NimbleParsec and macro-style code generation. · GitHub

Never tried it and it has not been updated in a long time but if you have the time, you might give it a shot.

None of these two address your need directly. But, in case you need a slightly different scenario in the future.

hugoestr

hugoestr

Thanks for the answers.

I went with a mixed solution. I got the LLM to generate a script that would will create the schema for a single table.

Last Post!

hugoestr

hugoestr

Thanks for bringing library up. I will probably need to do this in the future in any case, so I can explore it

Where Next?

Popular in Questions Top

New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
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 54006 488
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
openscript
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
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement