Sign inSign up

danibron/sql-dev-tools

By danibron

•Updated about 1 year ago

SQL development tools for various scenarios

Image
0

391

danibron/sql-dev-tools repository overview

⁠SQL Development Tools

A Docker image containing a suite of SQL development tools for working with various databases. This image includes tools for SQL linting, formatting, schema migration, and code generation, along with database clients for MySQL and PostgreSQL.

License: MIT

⁠Overview

This Docker image is built on ubuntu:25.04 and provides a development environment with the following tools:

  • SQLFluff: SQL linter and auto-formatter.
  • atlas: Database schema migration and inspection tool.
  • sqlc: Generates type-safe code (Go⁠, Python⁠, Kotlin⁠, TypeScript⁠) from SQL queries.
  • task: Task runner for automating workflows.
  • reflex: Live-reloading.
  • mysql-client: CLI for MySQL databases.
  • postgresql-client: CLI for PostgreSQL databases.

⁠Prerequisites

  • Docker⁠ or Podman⁠ installed on your system.
  • A working knowledge of SQL and database development.

⁠Installation

  1. Pull the Image (if published to a registry, e.g., Docker Hub):

    docker pull danibron/sql-dev-tools:latest
    
  2. Or Build the Image Locally: Clone the repository and build the Docker image:

    git clone https://github.com/DaniBr/sql-dev-tools.git
    cd sql-dev-tools
    docker build -t sql-dev-tools .
    

⁠Usage

⁠Running the Container

Start the container with the default command, which is reflex -s -g reflex.conf -- reflex -c reflex.conf (see here⁠):

docker run -it -v $(pwd)/sql:/sql sql-dev-tools:latest
  • -v $(pwd)/sql:/sql: Mounts a local sql directory to /sql in the container for your SQL files and reflex.conf configuration.
⁠Reflex Configuration

The tool uses a reflex.conf file for its configuration.
Any changes made to reflex.conf are hot reloaded, so you do not need to restart the tool when updating it.

Example reflex.conf:

-r 'schema\.sql$' --start-service -- task update_schema
⁠Pre-Reflex Configuration

The container automatically runs a pre-reflex task before starting the reflex file watcher. This allows you to perform setup operations like code generation, schema setup, or validation before development begins.

Example Taskfile.yml with pre-reflex:

version: '3'

tasks:
  pre-reflex:
    desc: "Setup tasks before starting file watching"
    cmds:
      - sqlc generate
      - sqlfluff lint --fail-if-violations ./src/**/*.sql
      - echo "Pre-reflex setup complete - starting file watcher"

  # Other tasks can be defined afterwards

If the pre-reflex task doesn't exist, the container will continue without error and start reflex normally.

⁠Example Workflow
  1. Lint SQL Files with SQLFluff:

    docker run -v $(pwd)/sql:/sql sql-dev-tools:latest sqlfluff lint /sql/queries.sql
    
  2. Manage Schema Migrations with atlas:

    docker run -v $(pwd)/sql:/sql sql-dev-tools:latest atlas schema apply --url "mysql://user:pass@host:3306/database_name" --file /sql/schema.sql
    
  3. Generate Go Code with sqlc:

    docker run -v $(pwd)/sql:/sql sql-dev-tools:latest sqlc generate
    
  4. Update procedures, functions, triggers with database client:

    psql -d $DATABASE_URL -f my-functions.sql
    mysql $DATABASE_NAME --user=$DATABASE_USER < my-functions.sql
    

⁠Contributing

Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository⁠.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -m 'Add your feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a pull request.

⁠License

This project is licensed under the MIT License. See the LICENSE⁠ file for details.

⁠Contact

For questions or support, please open an issue on the GitHub repository⁠ or contact the maintainer.

Tag summary

Content type

Image

Digest

sha256:0e85a8ae8…

Size

195.6 MB

Last updated

about 1 year ago

docker pull danibron/sql-dev-tools