Documentation/How Tos/Using SQLite With

From Apache OpenOffice Wiki
< Documentation‎ | How Tos
Revision as of 16:02, 16 August 2007 by Fpe (Talk | contribs)

Jump to: navigation, search



The aim of this guide is to help users to take advantage of the SQLite database engine as a data source.

What is SQLite?

SQLite is a basic database engine that implements most of the features of SQL92. Unlike PostgreSQL and MySQL, SQLite stores a whole data base with all its tables a single file. Other benefits are: database access requires no database server, database files can be freely shared between machines with different byte orders and databases can be up to 2 terabytes (241 bytes) in size. Plus it is fast (twice as much as PostgreSQL and MySQL for most operations) and has a small memory footprint.

Data management can be achieved in the following ways:

  1. Via a C/C++ Linux library or Windows DLL.
  2. Via an in-line program (sqlite: available under Linux and Windows) that makes it possible to create and to manage the files of data bases.
  3. Via the SQLite PHP module or, if you have, PHP version 5 internally to a SQLite database.
  4. Via ODBC (Linux and Windows) which allows any application supporting this standard to reach a SQLite database.
  5. Using the experimental SDBC SQLite driver

This guide addresses ODBC which uses to attach to databases and SQLite, in particular.

Why use SQLite with

The use of SQLite has many advantages:

  • The data base is in only one file, in contrast to dBASE which creates a file per table, making it easy to exchange databases between various users.
  • Java JRE or SDK is not required to support SQLite.
  • No server is needed (local or remote) to access a database.
  • ODBC drivers exist for *NIX and for Windows, thus enabling users of both environments to access data and exchange them.
  • A new SDBC driver (native to is available for experimentation.
  • Sophisticated graphic interfaces, such as those of msaccess, can be easily developed using the forms, queries, states and macros of These interfaces are stored separately in OpenOffice separate and can also be exchanged between users under UNIX or Windows.

and some disadvantages:

  • Modifying the structure of a SQLite table after its creation is not directly possible. This means that you cannot easily add fields nor to modify their properties once that the table is created. Therefore you must prepare the structure of your tables before creating them.
  • requires the use of the ODBC driver for accessing a SQLite database thus making this operation somewhat complicated. First it must be declared in ODBC and then in The native SDBC driver should correct this situation when it is production ready.
  • The initial database file cannot be created with but by using other tools.

In short, the principal advantages of the use of SQLite with are the format of data storage and the portability from one environment to another. In the list of disadvantages, the two last are not specific to SQLite, but are requirements of using ODBC. However, these are not as awkward as they do not take place during the initial creation of the database.


Installing the ODBC Driver for SQLite

For to access a SQLlite database in production, it is recommened that you install the ODBC driver. ODBC drivers for SQLite are independent of the SQLite project. However you can obtain a driver specifically developed by Christian Werner for from his site. This ODBC driver wraps the SQLite library and is available for Linux and Windows (for other UNIX, use the sources).


Under Linux

In order to be able to install the SQLite ODBC driver, unixODBC and SQLite must be installed first.


You will find most of the needed packages pre-installed in the majority of Linux distributions. For Mandrake, for example, install the following rpm files:

Documentation caution.png Check that your version of unixODBC is at least version 2.2.5. An older version will cause to hang when using the ODBC for SQLite driver. If your version is one of the older versions which is the case for Debian or Mandrake 9.1, it will be necessary for you to download and install a more recent version of unixODBC. If you do not find packages that are sufficiently recent in your distribution, download and compile the sources.
Documentation caution.png Compiling from the sources does not install the graphic utility ODBCConfig. Thus you will have to manually configure ODBC.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools