Code Monkey home page Code Monkey logo

dockerized_sqlfluff's Introduction

dockerized_sqlfluff

This is a Dockerfile that allows the user to run a containerized version of sqlfluff by Alan Cruickshank. The image is rebuilt weekly thanks to Jenkins.

To build

docker build -t sqlfluff .

To pull hosted image from Docker Hub

docker pull wesleydeanflexion/sqlfluff

To run

# mount and lint a file with locally-built image
docker run --rm -it -v $(pwd):/data sqlfluff filename.sql

# pipe a file to test with hosted image
docker run --rm -i wesleydeanflexion/sqlfluff - < filename.sql

Recursive scan of all SQL files

This will start in the current directory and scan all *.sql files (case-insensitive) with the hosted sqlfluff image. The sed statement will convert any container-specific paths back to paths meaningful to the host system.

docker run \
  --entrypoint '' \
  --rm \
  --interactive \
  --volume $(pwd):/data \
  wesleydeanflexion/sqlfluff \
  find . \
    -iname "*.sql" \
    -exec sqlfluff lint {} \; \
  | sed -Ee "s|/data/\.|$(pwd)|g"

Notes

  1. the file(s) to lint are sent as options to the sqlfluff container
  2. the container looks in /data/ to find the file(s) provided
  3. sqlfluff accepts - as a filename to read from STDIN (for piping)

Convenience alias

For your convenience, you may include the following into your shell configuration file (e.g., ~/.bashrc):

# this is the alias
alias sqlfluff='docker run --rm -i -v$(pwd):/data sqlfluff'

# here's how to use the alias
cat filename.sql | sqlfluff -
sqlfluff filename.sql

dockerized_sqlfluff's People

Contributors

wesley-dean-flexion avatar

Stargazers

 avatar

Watchers

 avatar  avatar

dockerized_sqlfluff's Issues

Join the SQLFluff Org?

Hi! I'm one of the maintainers from the newly-formed SqlFluff org. I saw your repo in a github search to see who's built tools around sqlfluff. I was wondering if you'd be interested in joining the maintainers group and migrating this repo to the new org.

You'd retain all the usual controls over dockerized_sqlfluff (the intention is definitely not to steal the project!), and adding it to the org would help new users find the project. What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.