Postmodern: PostgreSQL Access from Lisp
Postmodern is my new favorite database library. And for a couple simple reasons.
- Written for PostgreSQL. Screw those inferior databases.
- The ORM/abstraction layer is completely weak and totally optional. I’m not using it.
- Easy querying? How’s
(query "SQL HERE")? Try adding:row,:columnor:singleif you just want one row, one column, or a single value. - Trivial prepared statements. Check this out:
(defprepared insert-word
“INSERT INTO words (word, lang) VALUES ($1, $2)”))
(insert-word “my-word” “en”)
- Oh, you want a symbolic SQL syntax that doesn’t have the reader macro issues of CLSQL? How about this:
(defprepared word-exists
(sql (:select t :from ’words :where (:and (:= ’word ’$1)
(:= ’lang ’$2))))
:single)
(word-exists “my-word” “en”) ;; => t
(word-exists “your-word” “en”) ;; => nil
If you’re using Postmodern under CCL on your Intel 32-bit Mac, and you’re working with UTF-8 characters, you might want to add this line to the top of your Lisp or your ASD file after installing trivial-utf-8:
#+ccl
(push :unicode *features*)
Otherwise you will get really weird errors related to Unicode.