X-Git-Url: http://git.kpe.io/?p=hyperobject.git;a=blobdiff_plain;f=connect.lisp;h=e0495fc00fec45688f9ec9799703afb8e1e1d4de;hp=434a4f4e0591b494b27aca0fccca7c5dbd4f7499;hb=HEAD;hpb=d7f427eeebf7e6404ad2d1ebabbc8ebaa064898c diff --git a/connect.lisp b/connect.lisp index 434a4f4..e0495fc 100644 --- a/connect.lisp +++ b/connect.lisp @@ -1,4 +1,4 @@ -;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*- +;;;; -- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; @@ -7,15 +7,12 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: connect.lisp,v 1.1 2002/12/01 21:07:28 kevin Exp $ +;;;; $Id$ ;;;; -;;;; This file, part of Hyperobject-SQL, is -;;;; Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D. +;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg ;;;; ************************************************************************* -(in-package :hyperobject) -(declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3))) - +(in-package #:hyperobject) (defvar *ho-sql-db* "ho") (defun ho-sql-db () @@ -54,8 +51,8 @@ (defun sql-connect () "Connect to HO database, automatically used pooled connections" - (clsql:connect `(,(ho-sql-host) ,(ho-sql-db) ,(ho-sql-user) ,(ho-sql-passwd)) - :database-type *ho-sql-type* :pool t)) + (clsql:connect `(,(ho-sql-host) ,(ho-sql-db) ,(ho-sql-user) ,(ho-sql-passwd)) + :database-type *ho-sql-type* :pool t)) (defun sql-disconnect (conn) "Disconnect from HO database, but put connection back into pool" @@ -67,31 +64,21 @@ (defmacro with-sql-connection ((conn) &body body) `(let ((,conn (sql-connect))) (unwind-protect - (progn ,@body) + (progn ,@body) (when ,conn (clsql:disconnect :database ,conn))))) -(defun sql (stmt conn) - (if (string-equal "SELECT" (subseq stmt 0 6)) - (sql-query stmt conn) - (sql-execute stmt conn))) - (defun sql-query (cmd conn &key (types :auto)) (clsql:query cmd :database conn :types types)) (defun sql-execute (cmd conn) (clsql:execute-command cmd :database conn)) -(defun ho-sql (stmt) - (check-type stmt string) - (with-sql-connection (conn) - (sql stmt conn))) - ;;; Pool of open connections (defmacro with-mutex-sql ((conn) &body body) `(let ((,conn (sql-connect))) (unwind-protect - (progn ,@body) + (progn ,@body) (when ,conn (sql-disconnect ,conn))))) (defun mutex-sql-execute (cmd)