Appendix A. Using Korma – a Clojure DSL for SQL
In this book, we exclusively made use of YeSQL, a library that generates Clojure functions from native SQL. For an example application as small and simple as hipstr, YeSQL might be a tad overkill – its real beauty and elegance comes to light in larger projects that make use of large queries or lots of underlying database functionality. Furthermore, YeSQL does a decent job of abstracting away the underlying data model from the Clojure code.
That being said, there are many people who prefer using a domain specific language to interact with the database. This appendix will introduce you to Korma, a pure-Clojure DSL for SQL. This appendix will not cover Korma in its entirety (it's pretty full-fledged). Instead, this appendix will cover the following:
- How to tie object models back to database tables
- A light overview of selecting and inserting data using Korma
- Port the connection,
album-model
, anduser-model
namespaces...