Skip to content

s-m-i-t-a/database_url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DatabaseUrl

Build Status Coverage Status

Parse database URL and renturn keyword list for use with Ecto.

Installation

defp deps do
  [ {:database_url, "~> 0.1"}, ]
end

Usage

API

    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.

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.

Releases

No releases published

Packages

No packages published

Languages