Installation

Complete setup guide for CQL with PostgreSQL, MySQL, and SQLite.

Prerequisites

Crystal Language: Version 1.12.2 or higher

crystal --version

Database Server: Choose one or more:

  • SQLite - Built into most systems (development/testing)

  • PostgreSQL - brew install postgresql (production recommended)

  • MySQL - brew install mysql (legacy support)

Quick Start

1. Create Crystal Project

crystal init app myapp
cd myapp

2. Add Dependencies

# shard.yml
dependencies:
  cql:
    github: azutoolkit/cql
    version: "~> 0.0.435"

  # Choose your database driver
  sqlite3:
    github: crystal-lang/crystal-sqlite3
  # OR
  pg:
    github: will/crystal-pg
  # OR
  mysql:
    github: crystal-lang/crystal-mysql

3. Install and Test

4. Basic Setup

Database-Specific Setup

PostgreSQL Configuration

Connection Examples:

MySQL Configuration

SQLite Configuration

Environment Configuration

Multi-Environment Setup

File Structure

Connection Testing

Docker Development

Troubleshooting

Connection Issues:

  • Verify database server is running

  • Check connection string format

  • Confirm database exists

  • Verify user permissions

Dependencies:

Common Errors:

  • Database not found - Create database first

  • Permission denied - Check user privileges

  • Connection refused - Verify server is running

Next Steps

Last updated

Was this helpful?