summaryrefslogtreecommitdiff
path: root/docs/manual/smsd/dbi.rst
blob: 812c7092a478087becdaa68c89189545fd43c176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
.. _gammu-smsd-dbi:

DBI Backend
===========

Description
-----------

DBI backend stores all data in any database supported by `libdbi`_, which
parameters are defined by configuration (see :ref:`gammu-smsdrc` for description of
configuration options).

For tables description see :ref:`gammu-smsd-tables`.

This backend is based on :ref:`gammu-smsd-sql`.

.. note::

    The DBI driver is currently not supported on Windows because libdbi
    library does not support this platform.


Configuration
-------------

Before running :ref:`gammu-smsd` you need to create necessary tables in the
database. You can use examples given in database specific backends parts of
this manual to do that.

The configuration file then can look like:

.. code-block:: ini

    [smsd]
    service = sql
    driver = DBI_DRIVER
    host = localhost

.. seealso:: :ref:`gammu-smsdrc`

Supported drivers
-----------------

For complete list of drivers for `libdbi`_ see `libdbi-drivers`_ project. The
drivers for example include:

* ``sqlite3`` - for SQLite 3
* ``mysql`` - for MySQL
* ``pgsql`` - for PostgeSQL
* ``freetds`` - for MS SQL Server or Sybase

.. _libdbi: http://libdbi.sourceforge.net/
.. _libdbi-drivers: http://libdbi-drivers.sourceforge.net/

Creating tables
---------------

SQL script for creating tables in SQLite database:

.. literalinclude:: ../../sql/sqlite.sql
   :language: sql

.. note::

    You can find the script in :file:`docs/sql/sqlite.sql` as well. There are
    also scripts for other databases in same folder.

Upgrading tables
----------------

The easiest way to upgrade database structure is to backup old one and start
with creating new one based on example above.

For upgrading existing database, you can use changes described in
:ref:`smsd-tables-history` and then manually update ``Version`` field in
``gammu`` table.