r8936: merged classic-tests into tests
[clsql.git] / base / database.lisp
index 839204f3c57de01fde008441a32a6b1d858cf2f3..92599bb83075be8f92db89df5b42f5d21e9d219a 100644 (file)
@@ -1,7 +1,16 @@
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
 ;;;;
-;;;; $Id: $
+;;;; $Id$
+;;;;
+;;;; Base database functions
+;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+;;;; *************************************************************************
 
 (in-package #:clsql-base-sys)
 
@@ -23,7 +32,6 @@
 (defvar *default-database* nil
   "Specifies the default database to be used.")
 
-;;; usql
 (defun find-database (database &key (errorp t) (db-type nil))
   "The function FIND-DATABASE, given a string DATABASE, searches
 amongst the connected databases for one matching the name DATABASE. If
@@ -73,6 +81,10 @@ connection.  If make-default is true, then *default-database* is set
 to the new connection, otherwise *default-database is not changed. If
 pool is t the connection will be taken from the general pool, if pool
 is a conn-pool object the connection will be taken from this pool."
+
+  (when (stringp connection-spec)
+    (setq connection-spec (string-to-list-connection-spec connection-spec)))
+  
   (if pool
       (acquire-from-pool connection-spec database-type pool)
       (let* ((db-name (database-name-from-spec connection-spec database-type))
@@ -194,6 +206,21 @@ of full is NIL."
           (print-separator total-size))))
     (values)))
 
+(defun create-database (connection-spec &key database-type)
+  (when (stringp connection-spec)
+    (setq connection-spec (string-to-list-connection-spec connection-spec)))
+  (database-create connection-spec database-type))
+
+(defun probe-database (connection-spec &key database-type)
+  (when (stringp connection-spec)
+    (setq connection-spec (string-to-list-connection-spec connection-spec)))
+  (database-probe connection-spec database-type))
+
+(defun destroy-database (connection-spec &key database-type)
+  (when (stringp connection-spec)
+    (setq connection-spec (string-to-list-connection-spec connection-spec)))
+  (database-destroy connection-spec database-type))
+
 
 (defmacro with-database ((db-var connection-spec &rest connect-args) &body body)
   "Evaluate the body in an environment, where `db-var' is bound to the
@@ -215,3 +242,4 @@ The connection is automatically closed or released to the pool on exit from the
   `(progv '(*default-database*)
        (list ,database)
      ,@body))
+