Month: March 2014

SQL Date in Clojure

Just a small snippet of code for this week. Had a situation where needed to insert a Date value with Korma for one of my databases. Some minor troubleshooting led me to this code snippet that made life a lot easier. Note: the parameter date was a list of strings: (Date, Month, Year).

(defn make-sql-date [date]
    (java.util.GregorianCalendar. (Integer. (last date))
                                  (Integer. (second date))
                                  (Integer. (first date))))))

SQL in Clojure: Using Korma and Lobos for all your database needs

Let’s discuss SQL in Clojure. Specifically we’re going to take a look at two libraries and use their power to connect to databases, make SQL queries in an ‘Clojure-like’ manner, and be able to create, delete, and modify databases and tables. The two libraries we’re looking at today are Lobos and Korma. Lobos primarily handles create, alter, and drop commands, whereas Korma focuses on queries to the database (although does handle inserting new data, updating old data, and deleting data). With that let’s delve right into the world of SQL in Clojure!


Error Messaging with Programming Languages

Recently I had the misfortune of working on a project in VBA meaning I also had the misfortune of dealing with the useless Microsoft error messaging system (see the ever so helpful “Object required” message, followed by it’s close friend the “Object variable or With block variable not set” message). Furthermore, I’ve also had the far more pleasurable experience of working with Clojure recently. However, Clojure, too, is plagued by poor error messaging. Which had me thinking, what are some of the ways error messaging ought to be handled with different languages? Here’s the list I came up with: