Giter Club home page Giter Club logo

jdbc-format's Introduction

jdbc-format

Clojure functions for creating parameterized SQL statements.

jdbc-format is intended to be used with clojure.java.jdbc. It provides a mechanism of turning declarative templates into map-based parmeterized sql statements, eliminating the complexity of keeping track of parameter ordering. This is its one and only goal.

Supported Clojure Versions

jdbc-format is tested on Clojure 1.5.1 only. It may work on other Clojure versions.

Maturity

This is alpha quality software.

Installation

jdbc-format is available as a Maven artifact from Clojars:

[jdbc-format "0.2.0"]

jdbc-format follows Semantic Versioning. Please note that this means the public API for this library is not considered stable.

Documentation

The library exports three functions: sql, formatter and sql-params-fn. If you are the 99% use-case, you should only ever use sql-params-fn.

Codox API Documentation

Usage

(ns jdbc-format-usage
  (:require (jdbc-format (core :refer [sql-params-fn]))))

(def template
  "SELECT fruit FROM fruits WHERE color = :color AND citrus = :citrus?")

(def formatter
  "A function that turns maps into a parameterized SQL vector according
  to my template."
  (sql-params-fn template))

(formatter {:color "orange" :citrus? true})
;; ["SELECT fruit FROM fruits WHERE color = ? AND citrus = ?" "orange" true]

(formatter {:color "black"})
;; ["SELECT fruit FROM fruits WHERE color = ? AND citrus = ?" "black" nil]

(formatter {:color "yellow" :citrus? false :peel? true})
;; ["SELECT fruit FROM fruits WHERE color = ? AND citrus = ?" "yellow" false]

Changelog

v0.2.0

  • Remove the formatting function in favor of sql-params-fn, which covers the most common use case more effectively.

v0.1.0

  • Initial Release

Support

Please post any comments, concerns, or issues to the Github issues page.

License

Copyright © 2013 ToBeReplaced

Distributed under the Eclipse Public License, the same as Clojure. The license can be found at epl-v10.html in the root of this distribution.

jdbc-format's People

Contributors

tobereplaced avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.