database

Leveraging Clojure-power for SQL generation with HoneySQL

One of the most meaningful testaments to Clojure’s data-driven and lisp-powered design is the ability to use it to refine any of its transpiling processes, here SQL generation (elsewhere route generation, CSS generation, and of course its actual hosted languages, including Javascript or Java generation*). In this post I was tasked with refactoring a 3-arg function that reads from the database into a map-taking function that works with one, two, or three items in the map.

Quickly Creating DB namespaces with shell, emacs, and init.sql

My project design includes creating a file/namespace for each database table, with a suite of CRUD operations applying to each table. The end result is that I have functions like db.my-table/CREATE, READ, UPDATE, and DELETE available for each table. The strategy is as follows: Establish the template clj file that has all your CRUD operations Obtain all table names (e.g. from init.sql) Use a script to create a matching clj file based on template (1) customized to refer to the tables from (2) 1.