mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
56 lines
2.1 KiB
Common Lisp
56 lines
2.1 KiB
Common Lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;; CLOG - The Common Lisp Omnificent GUI ;;;;
|
|
;;;; (c) 2020-2022 David Botton ;;;;
|
|
;;;; License BSD 3 Clause ;;;;
|
|
;;;; ;;;;
|
|
;;;; clog-dbi.lisp ;;;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(cl:in-package :clog)
|
|
|
|
;;; CLOG Elements for Interfacing with databases. The current implemnitation
|
|
;;; uses cl-dbi. The purpose of creating "visual" elements is to facilitate
|
|
;;; their use in CLOG Builder
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Implementation - CLOG-Database
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defclass clog-database (clog-element)
|
|
((connection
|
|
:accessor database-connection
|
|
:initform nil
|
|
:documentation "Connection handle to database"))
|
|
(:documentation "Connection to database."))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;
|
|
;; create-database ;;
|
|
;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defgeneric create-database (clog-obj
|
|
&key hidden class html-id auto-place)
|
|
(:documentation "Create a new CLOG-Database element, for use in
|
|
CLOG-Builder. If not using builder use to connect:
|
|
(dbi:connect (database-connection clog-obj) ...)"))
|
|
|
|
(defmethod create-database ((obj clog-obj)
|
|
&key (hidden nil)
|
|
(class nil)
|
|
(html-id nil) (auto-place t))
|
|
(let ((new-obj (change-class (create-div obj :content ""
|
|
:hidden hidden
|
|
:class class
|
|
:html-id html-id
|
|
:auto-place auto-place)
|
|
'clog-database)))
|
|
;; default values for builder
|
|
(setf (attribute new-obj "data-clog-dbi-dbtype") ":sqlite3")
|
|
(setf (attribute new-obj "data-clog-dbi-dbname") ":memory:")
|
|
new-obj))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; database-connection ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defgeneric database-connection (clog-database)
|
|
(:documentation "Accessor to the database handle"))
|