ODBC

Libraries

The ODBC back-end requires access to an ODBC driver manager as well as ODBC drivers for the underlying database server. CLSQL has been tested with unixODBC ODBC Driver Manager as well as Microsoft's ODBC manager. These driver managers have been tested with the psqlODBC driver for PostgreSQL and the MyODBC driver for MySQL.

Initialization

Use

(asdf:operate 'asdf:load-op 'clsql-odbc)
	  

to load the ODBC back-end. The database type for the ODBC back-end is :odbc.

Connection Specification

Syntax of connection-spec

(dsn user password &key connection-string)

Description of connection-spec

dsn

String representing the ODBC data source name.

user

String representing the user name to use for authentication.

password

String representing the unencrypted password to use for authentication.

connection-string

Raw connection string passed to the underlying ODBC driver. Allows bypassing creating a DSN on the server.

Notes

FDDL

  • The :owner keyword argument to the FDDL functions for listing and testing for database objects is ignored.

Connect Examples


;; assumes a "mssql" DSN is configured on the lisp host, specifying database server
;;  and database name.
> (clsql:connect '("mssql" "database-user" "database-password") 
               :database-type :odbc)
=> #<CLSQL-ODBC:ODBC-DATABASE mssql/database-user OPEN {100756D123}>

;; no DSN on the lisp host, specify connection information via :connection-string
> (clsql:connect '("friendly-server-name" "friendly-username" "" 
		 :connection-string "DRIVER={FreeTDS};SERVER=mssql-server;DATABASE=database-name;UID=database-user;PWD=database-password;PORT=1433;TDS_Version=8.0;APP=clsql") 
               :database-type :odbc)
=> #<CLSQL-ODBC:ODBC-DATABASE friendly-server-name/friendly-username OPEN {100756D123}>

The friendly-server-name and friendly-username are only used when printing the connection object to a stream.