korma/Korma


Tasty SQL for Clojure.

http://sqlkorma.com

License: EPL-1.0

Language: Clojure


Korma

Tasty SQL for Clojure.

TravisCI Status

Build Status

Getting started

Simply add Korma as a dependency to your lein project:

[korma "0.4.3"]

Docs and Real Usage

To get rid of the ridiculously verbose logging, add the following into src/log4j.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <logger name="com.mchange">
    <level value="WARN"/>
  </logger>
</log4j:configuration>

And include log4j in your project.clj:

[log4j "1.2.15" :exclusions [javax.mail/mail
                            javax.jms/jms
                            com.sun.jdmk/jmxtools
                            com.sun.jmx/jmxri]]

Examples of generated queries:

(use 'korma.db)
(defdb db (postgres {:db "mydb"
                     :user "user"
                     :password "dbpass"}))

(use 'korma.core)
(defentity users)

(select users)
;; executes: SELECT * FROM users

(select users
  (fields :username :id))
;; executes: SELECT users.username, users.id FROM users

(select users
  (where {:username "chris"}))
;; executes: SELECT * FROM users WHERE (users.username = 'chris')

(select users 
  (where {:active true})
  (order :created)
  (limit 5)
  (offset 3))
;; executes: SELECT * FROM users WHERE (users.active = TRUE) ORDER BY users.created DESC LIMIT 5 OFFSET 3

(select users
  (where (or (= :username "chris")
             (= :email "chris@chris.com"))))
;; executes: SELECT * FROM users WHERE (users.username = 'chris' OR users.email = 'chris@chris.com')

(select users
  (where {:username [like "chris"]
          :status "active"
          :location [not= nil]}))
;; executes SELECT * FROM users WHERE (users.username LIKE 'chris' AND users.status = 'active' AND users.location IS NOT NULL)

(select users
  (where (or {:username "chris"
              :first "chris"}
             {:email [like "%@chris.com"]})))
;; executes: SELECT * FROM users WHERE ((users.username = 'chris' AND users.first = 'chris') OR users.email LIKE '%@chris.com)'


(defentity address
 (entity-fields :street :city :zip))

(defentity users
 (has-one address))

(select users
 (with address))
;; SELECT address.street, address.city, address.zip FROM users LEFT JOIN address ON users.id = address.users_id

License

Copyright (C) 2011 Chris Granger

Distributed under the Eclipse Public License, the same as Clojure.

Project Statistics

Sourcerank 12
Repository Size 801 KB
Stars 1,413
Forks 229
Watchers 45
Open issues 80
Dependencies 3
Contributors 55
Tags 20
Created
Last updated
Last pushed

Top Contributors See all

Immo Heikkinen Chris Granger AlexBaranosky Josh Tilles Chris Allen Vadim Geshel Jose Gomez RingMan ls4f Ben Burkert David Jarvis Tsutomu YANO Sarah Roberts Isaac Zeng Joseph Wilk Jim Crossley Dane Schneider Christopher Shea Marcelo Nomoto Takashi AOKI

Packages Referencing this Repo

kw-korma
Tasty SQL for Clojure
Latest release 0.3.1-SNAPSHOT - Published - 1.41K stars
venantius/korma
Tasty SQL for Clojure
Latest release 0.5.0-SNAPSHOT - Published - 1.41K stars
korma
Tasty SQL for Clojure
Latest release 0.5.0-RC1 - Updated - 1.41K stars
org.clojars.jgerman/korma
Tasty SQL for Clojure
Latest release 0.3.1-mm-SNAPSHOT - Updated - 1.41K stars
org.buntin/korma
Tasty SQL for Clojure
Latest release 0.3.0-beta9 - Published - 1.41K stars
org.clojars.doo/korma
Tasty SQL for Clojure
Latest release 0.3.1-SNAPSHOT - Published - 1.41K stars
com.gfredericks/korma
Tasty SQL for Clojure; forked and added sort of postgres array support.
Latest release 0.3.0-beta12 - Updated - 1.41K stars
org.clojars.myfreeweb/korma
Tasty SQL for Clojure
Latest release 0.3.0-RC4 - Published - 1.41K stars
org.clojars.jcrossley3/korma
Tasty SQL for Clojure, with a more liberal connection spec policy
Latest release 1.0.0-SNAPSHOT - Published - 1.41K stars
org.clojars.normanrichards/korma
Tasty SQL for Clojure
Latest release 0.3.1 - Published - 1.41K stars

Recent Tags See all

v.0.5.0-RC1 February 28, 2018
v0.4.3 August 02, 2016
v0.4.2 June 05, 2015
v0.4.1 May 15, 2015
v0.4.0 August 27, 2014
v0.3.3 August 01, 2014
v0.3.2 June 05, 2014
v0.3.1 April 15, 2014
v0.3.0 March 28, 2014
v0.3.0-RC8 March 25, 2014
v0.3.0-RC7 March 24, 2014
v0.3.0-RC6 February 01, 2014
v0.3.0-RC5 March 22, 2013
v0.3.0-RC4 February 15, 2013
v0.3.0-RC3 February 10, 2013

Interesting Forks See all

aaronc/Korma
Tasty SQL for Clojure.
Clojure - Updated - 2 stars - 1 forks
Deepakdubey90/Korma
Tasty SQL for Clojure.
Clojure - Updated - 1 stars
cloudfuji/Korma
Tasty SQL for Clojure.
Clojure - Updated - 1 stars
janherich/Korma
Tasty SQL for Clojure.
Clojure - EPL-1.0 - Last pushed - 1 stars
r0man/Korma
Tasty SQL for Clojure.
Clojure - EPL-1.0 - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2016-11-24 15:57:04 UTC

Login to resync this repository