用Clojure使用数据库[英] Use a database with Clojure

本文是小编为大家收集整理的关于用Clojure使用数据库的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

有哪些使用Clojure数据库的方法?

我从Clojure知道您可以用Java做任何事情,但这意味着我最终可能会使用过于复杂的(例如Hibernate)与Clojure Simplicity发生冲突的东西.有任何建议或评论吗?

推荐答案

clojure-contrib 有一个SQL库,它是JDBC周围的薄包装器( java.sql.Drivermanager).随附的测试文件具有其用法的一些示例.

其他推荐答案

我现在(截至2011年底)推荐 korma - "可口的SQL for Clojure"

这是一个美丽的小SQL DSL,这是网站上的一个示例:

(select users
  (aggregate (count :*) :cnt)
  (where (or (> :visits 20)
             (< :last_login a-year-ago))))

其他推荐答案

如果您不愿使用Java库,但想要包含简单性的东西,也许您会喜欢坚持.您只需要10分钟即可查看它是否适合您的需求.

本文地址:https://www.itbaoku.cn/post/597469.html

问题描述

What methods to use a database from Clojure are there?

I know from Clojure you can do anything you can with Java, but that means that I may end up using something overly complicated (like Hibernate) which clashes with Clojure simplicity. Any recommendations or comments?

推荐答案

clojure-contrib has an sql library which is a thin wrapper around JDBC (java.sql.DriverManager). The test file that comes with it has some examples of its usage.

其他推荐答案

I would now (as of late 2011) recommend Korma - "Tasty SQL for Clojure"

It's a beautiful little SQL DSL, here's an example from the website:

(select users
  (aggregate (count :*) :cnt)
  (where (or (> :visits 20)
             (< :last_login a-year-ago))))

其他推荐答案

If you are open to using a Java library but want something that embraces simplicity, perhaps you'll like Persist. It'll only take you 10 minutes to have a look and see if it fits your needs.