I'm excited to announce stch.sql.  A library for generating JDBC compatible 
SQL statements.  Based on code from Honey 
SQL<https://github.com/jkk/honeysql>and ideas from 
Lobos <http://budu.github.io/lobos/> and 
SQLingvo<https://github.com/r0man/sqlingvo>. 
Many thanks to the authors of those libraries.

Full documentation and examples can be found at 
https://github.com/stch-library/sql.

Add the following to your project dependencies to use:

[stch-library/sql "0.1.0"]

Example code:

(-> (select :users.name
                 :contacts.*
                '(date_format dob "%m/%d/%Y"))
      (from :users)
      (join :contacts
              '(= users.id contacts.userid))
      (where '(in users.status ["active" "pending"]))
      (group :users.status)
      (order-by (asc :contacts.last-name))
      (limit 25)
      (sql/format :quoting :mysql))

(create
  (-> (table :users)
        (integer :userID :unsigned :not-null)
        (integer :orgID)
        (set' :groups ["user" "admin"] (default "user"))
        (enum :status ["active" "inactive"])
        (decimal :ranking '(3 1) (default 0))
        (varchar :username [50])
        (chr :countryCode [2] (default "US"))
        (primary-key :userID)
        (index [:userID :orgID])
        (unique :username)
        (foreign-key :orgID '(orgs orgID) :on-delete-cascade))
 (engine :InnoDB)
 (collate :utf8-general-ci))

(alt
  (-> (table :users)
        (add (varchar :email [50]) (after :userID))
        (add (varchar :firstName [25]) :first)
        (add (index [:firstName :lastName]))
        (add (index '(username ranking)))
        (add (foreign-key :orgID '(orgs orgID) :on-delete-cascade))
        (change :username (varchar :username [100]))
        (drop-default :ranking)
        (set-default :ranking 1)
        (drop-column :countryCode)
        (drop-index :uname)
        (drop-primary-key)
        (drop-foreign-key :fk1)))

BTW, I'm currently looking for work as a Clojure developer.  If you like 
what you see, please hit me up.

David

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to