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.

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
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
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
jerry
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
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

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
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
joaquinalcerro
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 records...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement