Much later update (Jun 18, 2018)

This is a really bad idea and you shouldn’t do it. I’m leaving it here because I like seeing how my knowledge has changed and grown over the years. If you want something like this, you should use generics and methods instead.

Update

This is now a project!


This is my go-to macro for using databases in CL. It is a modification of a macro that I got from another site, which I can’t seem to find at the moment. I came across it not long ago looking for something else, so I know it’s still out there. I’ll update this post when I find it.

(defmodel people ((name :col-type text
                        :accessor people-name
                        :initarg :name
                        :export t))

Evaluating that will

  1. Create the database ‘people’.
  2. Create some functions
 people-select 
Find a record based on a query.
(people-select (:= 'name "Clint"))
 people-get 
Find a record with a uuid
 people-delete 
Remove a people record from the database.
 people-get-all 
Get all of the people records.
 people-update 
(defvar *t* (car (people-get-all)))           
(setf (people-name *t*) "Honk")               
(people-update *t*)

Now the challenge is to put this in a package and make it importable in a sane way.