# Mini SQL driver manual

## Preface

libdbi is a database abstraction layer written in C. It implements a framework that can utilize separate driver libraries for specific database servers. The libdbi-drivers project provides the drivers necessary to talk to the supported database servers.

This manual provides information about the Mini SQL driver. The manual is intended for programmers who write applications linked against libdbi and who want their applications to work with the Mini SQL driver.

Questions and comments about the Mini SQL driver should be sent to the libdbi-drivers-devel mailing list. Visit the libdbi-drivers-devel list page to subscribe and for further information. Questions and comments about the libdbi library should be sent to the appropriate libdbi mailing list.

The Mini SQL driver is maintained by Christian Stamgren.

## Introduction

Mini SQL is a light-weight SQL Database engine. It has a very small footprint and is well suited for embedded projects when you need the facility of a full blown database engine but have to be really carefull spending resources.

## Installation

This chapter describes the prerequisites and the procedures to build and install the Mini SQL driver from the sources.

### Prerequisites

The following packages have to be installed on your system:

libdbi

- This library provides the framework of the database abstraction layer which can utilize the sqlite driver to perform database operations. The download page as well as the mailing lists with bug reports and patches are accessible at sourceforge.net/projects/libdbi. The current version of the sqlite driver requires at least libdbi version 0.6.7.

Mini SQL

- Yes, you'll need the acctual database installed. Funny isn't it? http://www.hugnes.com.au/producs/msql/

### Build and install the Mini SQL driver

First you have to unpack the libdbi-drivers archive in a suitable directory. Unpacking will create a new subdirectory `libdbi-drivers-X.Y` where "X.Y" denotes the version:

    $ tar -xzf libdbi-drivers-x.y.tar.gz

The libdbi-drivers project consists of several drivers that use a common build system. Therefore you must tell configure explicitly that you want to build the Mini SQL driver (you can list as many drivers as you want to build):

    $ cd libdbi-drivers

    $ ./configure --with-msql

Run `./configure --help` to find out about additional options.

Then build the driver with the command:

    $ make

Please note that you may have to invoke `gmake`, the GNU version of make, on some systems.

Then install the driver with the command (you'll need root permissions to do this):

    $ make install

To test the operation of the newly installed driver, use the command:

    $ make check

This command creates and runs a test program that performs a few basic input and output tests. The program will ask for a database name and a host name. If you havn't configured Mini SQL to use TCP just press enter at the hostname selection to pass NULL to Mini SQL's `connect()` function indicating that you want to use a local socket.

## Driver options

Your application has to initialize libdbi drivers by setting some driver options with the `dbi_conn_set_option()` and the `dbi_conn_set_option_numeric()` library functions. Mini SQL uses the following options::

dbname

- The name of the database you want to connect to. `dbname` can be any existing database in the Mini SQL installation created with `msqladmin create dbname`.

host

- This is the name or ip-address of the host where the Mini SQL database is located.

  If you want to connect to a database on localhost don't use this option. Specifying localhost will force TCP usage instedd of UNIX Domain socket usage (if the server is configured for TCP) Mini SQL is much faster using a UNIX domain socket.