Phoenix (or Ecto) defaults PostgreSQL as their database of choice. What if you just want to do something simple or just start learning Phoenix and too lazy to set up a Postgres server (like me)?
After setting up your Erlang and Elixir in your machine, you need to install hex
. If you haven't had it installed, run this:
mix local.hex
Then you need to install Phoenix application generator:
mix archive.install hex phx_new
To kick start your Phoenix project, run this line:
mix phx.new sqlite_app --database sqlite3
Now you're ready to develop your next awesome Phoenix project with SQLite.
What Happened?
The --database
flag tells the generator that we want to use SQLite in our project and added ecto_sqlite3
as a dependency so we can use it with Ecto
.
Actually, Phoenix is well documented (and from what I heard, Elixir projects are generally well documented). You can find most of what you want to do when kickstarting your Phoenix project in this hexdocs page.
Now run:
mix ecto.create
to create your SQLite database file in your project direcory.
I hope this helps and hope you have some fun times ahead!
Oldest comments (4)
Thanks; I'm learning Elixir, and wanted something less than Postgres.
Same here! I was just trying to learn Phoenix. Setting up a Postgres for it feels like a lot of commitment.
Thanks! I couldn't find this easily in the docs.
Thanx!