Data to Database with elixir

Sis Ccr
Dec 16, 2020

--

Small elixir snippets that actually works, now thats called fun.

Automations

Automating tedious jobs are sure fun. I am writting an Roomfinder application as a part of my through learning elixir, phoenix and web development as a whole.

I am from Nepal. Nepal has 77 district and 7 States. I needed to create a database table from it.

All districts and corresponding states of Nepal

I added above json file in priv/static/json/district_list.json

Then generated context using

mix phx.gen.context Districts District districts name state:integer

mix ecto.migrate

Then in seeds.exs file I added a script to read the file and loop through all and insert it to database.

And thats it without any error all address are now inside my postgres database.

--

--

Sis Ccr
Sis Ccr

Written by Sis Ccr

Depths of ocean could not swallow me.

No responses yet