Skip to content
Yacine Petitprez edited this page Jun 7, 2018 · 6 revisions

Installation

In shards.yml, please add theses lines:

dependencies:
  clear:
    github: anykeyh/clear

Then in your code, add the requirement:

require "clear"

Initialization

Connection can be initialized by Clear::SQL.init(uri) method:

Clear::SQL.init("postgres://[USER]:[PASSWORD]@[HOST]/[DATABASE]")

You can fine tune your connection, accessible by the Clear::SQL.connection object. Check the will/crystal-pg shards documentations for more informations.

Additional parameters like retry_attempts, retry_delay etc... can be passed to the URI. Please check the official db documentation

By choice, Clear doesn't offers any configuration file (e.g. database.yml), so you need to setup your own architecture to handle different build targets.

Logging

By default, logging of SQL output is disabled. To enable it, you need to change the logger verbosity level:

Clear.logger.level = ::Logger::DEBUG

Clone this wiki locally