GAMMU-SMSD-DBI(7)
π gammu-smsd-dbi β like, the whole manual page, bestie
okay so this is GAMMU-SMSD-DBI(7), part of the gammu manual family. grab a snack, we're getting into it π
β¨ NAME β¨
gammu-smsd-dbi β it's a backend for gammu-smsd(1) that uses the DBI abstraction layer so you can use, like, any supported database as your message storage. no cap. π
π¦ DESCRIPTION π¦
So the DBI backend stores all the data in any database that libdbi supports (that's libdbi.sourceforge.net, iykyk), and the parameters for it are defined by your configuration β go peek at the SMSD Configuration File section (the #gammu-smsdrc one) for all the deets on those configuration options.
For the tables description, you want the SMSD Database Structure section (#gammu-smsd-tables). that's where it lives π
This backend is based on SQL Service (#gammu-smsd-sql), periodt.
Note (important, bestie π): the DBI driver is currently not supported on Windows, because the libdbi library just... doesn't support that platform. it's giving incompatibility. π
πΈ CONFIGURATION πΈ
Before you run gammu-smsd (#gammu-smsd), you literally have to create the necessary tables in the database first. You can use the examples given in the database-specific backends parts of this manual to do that. slay, copy-paste era π«Ά
The configuration file then can look like this:
[smsd]
service = sql
driver = DBI_DRIVER
host = localhost
See also: π the SMSD Configuration File section (#gammu-smsdrc).
π SUPPORTED DRIVERS π
For the complete list of drivers for libdbi (libdbi.sourceforge.net), go check out the libdbi-drivers (libdbi-drivers.sourceforge.net) project. The drivers for example include:
sqlite3β for SQLite 3 πͺmysqlβ for MySQLpgsqlβ for PostgeSQL (yes that's how it's spelled here, not me, I don't make the rules π )freetdsβ for MS SQL Server or Sybase
π CREATING TABLES FOR SQLITE π
Here's the SQL script for creating tables in an SQLite database β huge, iconic, don't retype it by hand, fr fr:
CREATE TABLE gammu (
Version INTEGER NOT NULL DEFAULT 0 PRIMARY KEY
);
INSERT INTO gammu (Version) VALUES (18);
CREATE TABLE inbox (
UpdatedInDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
ReceivingDateTime NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
InsertIntoDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
Text TEXT NOT NULL,
SenderNumber TEXT NOT NULL DEFAULT '',
Coding TEXT NOT NULL DEFAULT 'Default_No_Compression',
UDH TEXT NOT NULL,
SMSCNumber TEXT NOT NULL DEFAULT '',
Class INTEGER NOT NULL DEFAULT -1,
TextDecoded TEXT NOT NULL DEFAULT '',
ID INTEGER PRIMARY KEY AUTOINCREMENT,
MessageID INTEGER NOT NULL DEFAULT 0,
SequencePosition INTEGER NOT NULL DEFAULT 1,
PartCount INTEGER NOT NULL DEFAULT 1,
RecipientID TEXT NOT NULL,
Processed TEXT NOT NULL DEFAULT 'false',
Status INTEGER NOT NULL DEFAULT -1,
CHECK (Coding IN
('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression'))
);
CREATE INDEX inbox_message ON inbox(MessageID, SequencePosition);
CREATE INDEX inbox_insert ON inbox(InsertIntoDB);
CREATE TRIGGER update_inbox_time UPDATE ON inbox
BEGIN
UPDATE inbox SET UpdatedInDB = datetime('now', 'localtime') WHERE ID = old.ID;
END;
CREATE TABLE outbox (
UpdatedInDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
InsertIntoDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
SendingDateTime NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
SendBefore time NOT NULL DEFAULT '23:59:59',
SendAfter time NOT NULL DEFAULT '00:00:00',
SendDays INTEGER NOT NULL DEFAULT 127,
Text TEXT,
DestinationNumber TEXT NOT NULL DEFAULT '',
Coding TEXT NOT NULL DEFAULT 'Default_No_Compression',
UDH TEXT,
Class INTEGER DEFAULT -1,
TextDecoded TEXT NOT NULL DEFAULT '',
ID INTEGER PRIMARY KEY AUTOINCREMENT,
MultiPart TEXT NOT NULL DEFAULT 'false',
RelativeValidity INTEGER DEFAULT -1,
SenderID TEXT,
SendingTimeOut NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
DeliveryReport TEXT DEFAULT 'default',
CreatorID TEXT NOT NULL,
Retries INTEGER DEFAULT 0,
Priority INTEGER DEFAULT 0,
Status TEXT NOT NULL DEFAULT 'Reserved',
StatusCode INTEGER NOT NULL DEFAULT -1,
CHECK (Coding IN
('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression')),
CHECK (DeliveryReport IN ('default','yes','no')),
CHECK (Status IN
('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending',
'DeliveryUnknown','Error','Reserved'))
);
CREATE INDEX outbox_date ON outbox(SendingDateTime, SendingTimeOut);
CREATE INDEX outbox_sender ON outbox(SenderID);
CREATE TRIGGER update_outbox_time UPDATE ON outbox
BEGIN
UPDATE outbox SET UpdatedInDB = datetime('now', 'localtime') WHERE ID = old.ID;
END;
CREATE TABLE outbox_multipart (
Text TEXT,
Coding TEXT NOT NULL DEFAULT 'Default_No_Compression',
UDH TEXT,
Class INTEGER DEFAULT -1,
TextDecoded TEXT DEFAULT NULL,
ID INTEGER,
SequencePosition INTEGER NOT NULL DEFAULT 1,
Status TEXT NOT NULL DEFAULT 'Reserved',
StatusCode INTEGER NOT NULL DEFAULT -1,
CHECK (Coding IN
('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression')),
CHECK (Status IN
('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending',
'DeliveryUnknown','Error','Reserved')),
PRIMARY KEY (ID, SequencePosition)
);
CREATE TABLE phones (
ID TEXT NOT NULL,
UpdatedInDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
InsertIntoDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
TimeOut NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
Send TEXT NOT NULL DEFAULT 'no',
Receive TEXT NOT NULL DEFAULT 'no',
IMEI TEXT PRIMARY KEY NOT NULL,
IMSI TEXT NOT NULL,
NetCode TEXT DEFAULT 'ERROR',
NetName TEXT DEFAULT 'ERROR',
Client TEXT NOT NULL,
Battery INTEGER NOT NULL DEFAULT -1,
Signal INTEGER NOT NULL DEFAULT -1,
Sent INTEGER NOT NULL DEFAULT 0,
Received INTEGER NOT NULL DEFAULT 0
);
CREATE TRIGGER update_phones_time UPDATE ON phones
BEGIN
UPDATE phones SET UpdatedInDB = datetime('now', 'localtime') WHERE IMEI = old.IMEI;
END;
CREATE TABLE sentitems (
UpdatedInDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
InsertIntoDB NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
SendingDateTime NUMERIC NOT NULL DEFAULT (datetime('now', 'localtime')),
DeliveryDateTime NUMERIC NULL,
Text TEXT NOT NULL,
DestinationNumber TEXT NOT NULL DEFAULT '',
Coding TEXT NOT NULL DEFAULT 'Default_No_Compression',
UDH TEXT NOT NULL,
SMSCNumber TEXT NOT NULL DEFAULT '',
Class INTEGER NOT NULL DEFAULT -1,
TextDecoded TEXT NOT NULL DEFAULT '',
ID INTEGER,
SenderID TEXT NOT NULL,
SequencePosition INTEGER NOT NULL DEFAULT 1,
Status TEXT NOT NULL DEFAULT 'SendingOK',
StatusError INTEGER NOT NULL DEFAULT -1,
TPMR INTEGER NOT NULL DEFAULT -1,
RelativeValidity INTEGER NOT NULL DEFAULT -1,
CreatorID TEXT NOT NULL,
StatusCode INTEGER NOT NULL DEFAULT -1,
CHECK (Status IN
('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending',
'DeliveryUnknown','Error')),
CHECK (Coding IN
('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression')) ,
PRIMARY KEY (ID, SequencePosition)
);
CREATE INDEX sentitems_date ON sentitems(DeliveryDateTime);
CREATE INDEX sentitems_tpmr ON sentitems(TPMR);
CREATE INDEX sentitems_dest ON sentitems(DestinationNumber);
CREATE INDEX sentitems_sender ON sentitems(SenderID);
CREATE TRIGGER update_sentitems_time UPDATE ON sentitems
BEGIN
UPDATE sentitems SET UpdatedInDB = datetime('now', 'localtime') WHERE ID = old.ID;
END;
Note: you can find the script in docs/sql/sqlite.sql as well β and there are also scripts for other databases in that same folder. so convenient, honestly π§
π UPGRADING TABLES π
The easiest way to upgrade your database structure is to back up the old one and then start fresh by creating the new one based on the example above. clean slate energy β¨
But if you're upgrading an existing database, you can use the changes described in the History of database structure section (#smsd-tables-history) and then manually update the Version field in the gammu table. manual but manageable, bestie π
π Author π
Michal ΔihaΕ <michal@cihar.com> β king behavior π
π Copyright π
2009-2015, Michal ΔihaΕ <michal@cihar.com>
okay that's the whole thing, you ate that π«Ά this page is version 1.45.0, dated Sep 16, 2026 β go forth and store those messages, icon ππ¦π
π¦ where this page comes from
- arch rolling: gammu 1.45.0-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms