Next Previous Up Top Contents Index

16 The SQL Package

connect

Function

Summary

Opens a connection to a database.
Package

sql

Signature

connect connection-spec &key if-exists database-type => database

Arguments

connection-spec

The connection specifications.

if-exists

A keyword.

database-type

A database type.

Values

database

A database.

Description

Theconnect function opens a connection to a database of database-type. The default value for database-type is*default-database-type*. The connection-spec depends on the type of the database to connect to. For databases of type:odbc, the connection specification is a string of the format
"datasource-name/username/password"

where datasource-name is the name of an ODBC datasource, and username and password are a valid username and password. If the datasource does not require a username and password they can be omitted.
The variable*default-database* is set to an instance of the database opened and the instance is returned. The argument if-exists modifies the behavior ofconnect as follows:
:new

Makes a new connection even if connections to the same database already exist.

:warn-new

Makes a new connection but warns about existing connections.

:error

Makes a new connection but signals an error for existing connections.

:warn-old

Selects old connection if one exists (and warns) or makes a new one.

:old

Selects old connection if one exists or makes a new one.

The default value of if-exists is the value of
*connect-if-exists*.
Example

The following example connects LispWorks to theinfo database.
(connect "info")

The next example connects to the ODBC databasepersonnel using the username "admin" and the password "secret".
(connect "personnel/admin/secret" :database-type :odbc)

See also

disconnect
status
find-database
database-name
connected-databases


LispWorks Reference Manual - 15 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker