Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s-m-i-t-a/database_url
Database URL parser for Elixir
https://github.com/s-m-i-t-a/database_url
database elixir hacktoberfest
Last synced: about 1 month ago
JSON representation
Database URL parser for Elixir
- Host: GitHub
- URL: https://github.com/s-m-i-t-a/database_url
- Owner: s-m-i-t-a
- License: bsd-3-clause
- Created: 2015-05-15T17:09:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-30T11:59:54.000Z (11 months ago)
- Last Synced: 2024-11-01T08:33:57.373Z (about 1 month ago)
- Topics: database, elixir, hacktoberfest
- Language: Elixir
- Homepage:
- Size: 16.6 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Parse database URL and return keyword list for use with Ecto. (ORM and Datamapping)
- fucking-awesome-elixir - database_url - Parse database URL and return keyword list for use with Ecto. (ORM and Datamapping)
- awesome-elixir - database_url - Parse database URL and return keyword list for use with Ecto. (ORM and Datamapping)
README
# DatabaseUrl
[![Build Status](https://semaphoreci.com/api/v1/projects/91fb642e-351c-40c4-a0d4-7c45e4e0f7bf/431905/shields_badge.svg)](https://semaphoreci.com/smita/database_url)
[![Coverage Status](https://coveralls.io/repos/s-m-i-t-a/database_url/badge.svg?branch=master)](https://coveralls.io/r/s-m-i-t-a/database_url?branch=master)Parse database URL and renturn keyword list for use with Ecto.
## Installation
```elixir
defp deps do
[ {:database_url, "~> 0.1"}, ]
end
```## Usage
### API
```elixir
iex> url = "postgres://localhost/database?size=30&ssl=true&encoding=utf-8"
iex> options = DatabaseUrl.parse(url)
[host: "localhost", database: "database", adapter: Ecto.Adapters.Postgres,
size: 30, ssl: true, encoding: "utf-8"]
```### Use with Phoenix + Ecto
Use in project config and assume `DATABASE_URL` environment variable is set.
```elixir
Code.require_file("../deps/database_url/lib/database_url.ex", __DIR__)# Configure your database
config :myapp, MyApp.Repo, DatabaseUrl.parse(System.get_env("DATABASE_URL"))
```On first line in `config.exs` must be added `Code.require_file("../deps/database_url/lib/database_url.ex", __DIR__)`,
otherwise isn't module loaded.