Name

DATABASE-NAME-FROM-SPEC — Return the database name string corresponding to the given connection specification.Generic Function

Syntax

	  database-name-from-spec connection-spec database-type => name

Arguments and Values

connection-spec

A connection specification, whose structure and interpretation are dependent on the database-type.

database-type

A database type specifier, i.e. a keyword.

name

A string denoting a database name.

Description

This generic function takes a connection specification and a database type and returns the database name of the database object that would be created had connect been called with the given connection specification and database types.

This function is useful in determining a database name from the connection specification, since the way the connection specification is converted into a database name is dependent on the database type.

Examples

(database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
=> "dent/newesim/dent"
(connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
=> #<CLSQL-MYSQL:MYSQL-DATABASE {48391DCD}>
(database-name *default-database*)
=> "dent/newesim/dent"

(database-name-from-spec '(nil "template1" "dent" nil) :postgresql)
=> "/template1/dent"
(connect '(nil "template1" "dent" nil) :database-type :postgresql)
=> #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
(database-name *default-database*)
=> "/template1/dent"

(database-name-from-spec '("www.pmsf.de" "template1" "dent" nil) :postgresql)
=> "www.pmsf.de/template1/dent"

(find-database "dent/newesim/dent")
=> #<CLSQL-MYSQL:MYSQL-DATABASE {484E91C5}>
(find-database "/template1/dent")
=> #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
(find-database "www.pmsf.de/template1/dent" nil)
=> NIL
(find-database **)
=> #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
	

Side Effects

None.

Affected by

None.

Exceptional Situations

If the value of connection-spec is not a valid connection specification for the given database type, an error of type clsql-invalid-spec-error might be signalled.

See Also

connect

Notes

database-name-from-spec is a CLSQL extension.