GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  GAMMU-SMSD-MYSQL (7)

NAME

gammu-smsd-mysql - gammu-smsd(1) backend using MySQL database server as a message storage \$1 \n[an-margin] level \n[rst2man-indent-level] level margin: \n[rst2man-indent\n[rst2man-indent-level]] - \n[rst2man-indent0] \n[rst2man-indent1] \n[rst2man-indent2]

CONTENTS

Description
Configuration
Privileges
Creating Tables
Upgrading Tables
Author
Copyright

DESCRIPTION

MYSQL backend stores all data in a  MySQL database server, which parameters are defined by configuration (see gammu-smsdrc for description of configuration options).

For tables description see gammu-smsd-tables.

This backend is based on gammu-smsd-sql.

CONFIGURATION

Before running gammu-smsd you need to create necessary tables in the database, which is described below.

The configuration file then can look like:


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


SEE ALSO: gammu-smsdrc

PRIVILEGES

The user accessing the database does not need much privileges, the following privileges should be enough:


GRANT USAGE ON *.* TO \(aqsmsd\(aq@\(aqlocalhost\(aq IDENTIFIED BY \(aqpassword\(aq;

GRANT SELECT, INSERT, UPDATE, DELETE ON `smsd`.* TO \(aqsmsd\(aq@\(aqlocalhost\(aq;

CREATE DATABASE smsd;

NOTE: For creating the SQL tables you need more privileges, especially for creating triggers, which are used for some functionality.

CREATING TABLES

SQL script for creating tables in MySQL database:


--
-- Database for Gammu SMSD
--
-- In case you get errors about not supported charset, please
-- replace utf8mb4 with utf8.

-- --------------------------------------------------------

-- -- Table structure for table `daemons` --

CREATE TABLE `daemons` ( `Start` text NOT NULL, `Info` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

-- -- Dumping data for table `daemons` --

-- --------------------------------------------------------

-- -- Table structure for table `gammu` --

CREATE TABLE `gammu` ( `Version` integer NOT NULL default \(aq0\(aq ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

-- -- Dumping data for table `gammu` --

INSERT INTO `gammu` (`Version`) VALUES (15);

-- --------------------------------------------------------

-- -- Table structure for table `inbox` --

CREATE TABLE `inbox` ( `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `ReceivingDateTime` timestamp NOT NULL default \(aq0000-00-00 00:00:00\(aq, `Text` text NOT NULL, `SenderNumber` varchar(20) NOT NULL default \(aq\(aq, `Coding` enum(\(aqDefault_No_Compression\(aq,\(aqUnicode_No_Compression\(aq,\(aq8bit\(aq,\(aqDefault_Compression\(aq,\(aqUnicode_Compression\(aq) NOT NULL default \(aqDefault_No_Compression\(aq, `UDH` text NOT NULL, `SMSCNumber` varchar(20) NOT NULL default \(aq\(aq, `Class` integer NOT NULL default \(aq-1\(aq, `TextDecoded` text NOT NULL default \(aq\(aq, `ID` integer unsigned NOT NULL auto_increment, `RecipientID` text NOT NULL, `Processed` enum(\(aqfalse\(aq,\(aqtrue\(aq) NOT NULL default \(aqfalse\(aq, PRIMARY KEY `ID` (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;

-- -- Dumping data for table `inbox` --

-- --------------------------------------------------------

-- -- Table structure for table `outbox` --

CREATE TABLE `outbox` ( `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `InsertIntoDB` timestamp NOT NULL default \(aq0000-00-00 00:00:00\(aq, `SendingDateTime` timestamp NOT NULL default \(aq0000-00-00 00:00:00\(aq, `SendBefore` time NOT NULL DEFAULT \(aq23:59:59\(aq, `SendAfter` time NOT NULL DEFAULT \(aq00:00:00\(aq, `Text` text, `DestinationNumber` varchar(20) NOT NULL default \(aq\(aq, `Coding` enum(\(aqDefault_No_Compression\(aq,\(aqUnicode_No_Compression\(aq,\(aq8bit\(aq,\(aqDefault_Compression\(aq,\(aqUnicode_Compression\(aq) NOT NULL default \(aqDefault_No_Compression\(aq, `UDH` text, `Class` integer default \(aq-1\(aq, `TextDecoded` text NOT NULL default \(aq\(aq, `ID` integer unsigned NOT NULL auto_increment, `MultiPart` enum(\(aqfalse\(aq,\(aqtrue\(aq) default \(aqfalse\(aq, `RelativeValidity` integer default \(aq-1\(aq, `SenderID` varchar(255), `SendingTimeOut` timestamp NULL default \(aq0000-00-00 00:00:00\(aq, `DeliveryReport` enum(\(aqdefault\(aq,\(aqyes\(aq,\(aqno\(aq) default \(aqdefault\(aq, `CreatorID` text NOT NULL, `Retries` int(3) default 0, PRIMARY KEY `ID` (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

CREATE INDEX outbox_date ON outbox(SendingDateTime, SendingTimeOut); CREATE INDEX outbox_sender ON outbox(SenderID);

-- -- Dumping data for table `outbox` --

-- --------------------------------------------------------

-- -- Table structure for table `outbox_multipart` --

CREATE TABLE `outbox_multipart` ( `Text` text, `Coding` enum(\(aqDefault_No_Compression\(aq,\(aqUnicode_No_Compression\(aq,\(aq8bit\(aq,\(aqDefault_Compression\(aq,\(aqUnicode_Compression\(aq) NOT NULL default \(aqDefault_No_Compression\(aq, `UDH` text, `Class` integer default \(aq-1\(aq, `TextDecoded` text default NULL, `ID` integer unsigned NOT NULL default \(aq0\(aq, `SequencePosition` integer NOT NULL default \(aq1\(aq, PRIMARY KEY (`ID`, `SequencePosition`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

-- -- Dumping data for table `outbox_multipart` --

-- --------------------------------------------------------

-- -- Table structure for table `pbk` --

CREATE TABLE `pbk` ( `ID` integer NOT NULL auto_increment, `GroupID` integer NOT NULL default \(aq-1\(aq, `Name` text NOT NULL, `Number` text NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

-- -- Dumping data for table `pbk` --

-- --------------------------------------------------------

-- -- Table structure for table `pbk_groups` --

CREATE TABLE `pbk_groups` ( `Name` text NOT NULL, `ID` integer NOT NULL auto_increment, PRIMARY KEY `ID` (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;

-- -- Dumping data for table `pbk_groups` --

-- --------------------------------------------------------

-- -- Table structure for table `phones` --

CREATE TABLE `phones` ( `ID` text NOT NULL, `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `InsertIntoDB` timestamp NOT NULL default \(aq0000-00-00 00:00:00\(aq, `TimeOut` timestamp NOT NULL default \(aq0000-00-00 00:00:00\(aq, `Send` enum(\(aqyes\(aq,\(aqno\(aq) NOT NULL default \(aqno\(aq, `Receive` enum(\(aqyes\(aq,\(aqno\(aq) NOT NULL default \(aqno\(aq, `IMEI` varchar(35) NOT NULL, `NetCode` varchar(10) default \(aqERROR\(aq, `NetName` varchar(35) default \(aqERROR\(aq, `Client` text NOT NULL, `Battery` integer NOT NULL DEFAULT -1, `Signal` integer NOT NULL DEFAULT -1, `Sent` int NOT NULL DEFAULT 0, `Received` int NOT NULL DEFAULT 0, PRIMARY KEY (`IMEI`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

-- -- Dumping data for table `phones` --

-- --------------------------------------------------------

-- -- Table structure for table `sentitems` --

CREATE TABLE `sentitems` ( `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `InsertIntoDB` timestamp NOT NULL default \(aq0000-00-00 00:00:00\(aq, `SendingDateTime` timestamp NOT NULL default \(aq0000-00-00 00:00:00\(aq, `DeliveryDateTime` timestamp NULL, `Text` text NOT NULL, `DestinationNumber` varchar(20) NOT NULL default \(aq\(aq, `Coding` enum(\(aqDefault_No_Compression\(aq,\(aqUnicode_No_Compression\(aq,\(aq8bit\(aq,\(aqDefault_Compression\(aq,\(aqUnicode_Compression\(aq) NOT NULL default \(aqDefault_No_Compression\(aq, `UDH` text NOT NULL, `SMSCNumber` varchar(20) NOT NULL default \(aq\(aq, `Class` integer NOT NULL default \(aq-1\(aq, `TextDecoded` text NOT NULL default \(aq\(aq, `ID` integer unsigned NOT NULL default \(aq0\(aq, `SenderID` varchar(255) NOT NULL, `SequencePosition` integer NOT NULL default \(aq1\(aq, `Status` enum(\(aqSendingOK\(aq,\(aqSendingOKNoReport\(aq,\(aqSendingError\(aq,\(aqDeliveryOK\(aq,\(aqDeliveryFailed\(aq,\(aqDeliveryPending\(aq,\(aqDeliveryUnknown\(aq,\(aqError\(aq) NOT NULL default \(aqSendingOK\(aq, `StatusError` integer NOT NULL default \(aq-1\(aq, `TPMR` integer NOT NULL default \(aq-1\(aq, `RelativeValidity` integer NOT NULL default \(aq-1\(aq, `CreatorID` text NOT NULL, PRIMARY KEY (`ID`, `SequencePosition`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

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);

-- -- Dumping data for table `sentitems` --

-- -- Triggers for setting default timestamps --

DELIMITER //

CREATE TRIGGER inbox_timestamp BEFORE INSERT ON inbox FOR EACH ROW BEGIN IF NEW.ReceivingDateTime = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.ReceivingDateTime = CURRENT_TIMESTAMP(); END IF; END;//

CREATE TRIGGER outbox_timestamp BEFORE INSERT ON outbox FOR EACH ROW BEGIN IF NEW.InsertIntoDB = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.InsertIntoDB = CURRENT_TIMESTAMP(); END IF; IF NEW.SendingDateTime = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.SendingDateTime = CURRENT_TIMESTAMP(); END IF; IF NEW.SendingTimeOut = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.SendingTimeOut = CURRENT_TIMESTAMP(); END IF; END;//

CREATE TRIGGER phones_timestamp BEFORE INSERT ON phones FOR EACH ROW BEGIN IF NEW.InsertIntoDB = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.InsertIntoDB = CURRENT_TIMESTAMP(); END IF; IF NEW.TimeOut = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.TimeOut = CURRENT_TIMESTAMP(); END IF; END;//

CREATE TRIGGER sentitems_timestamp BEFORE INSERT ON sentitems FOR EACH ROW BEGIN IF NEW.InsertIntoDB = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.InsertIntoDB = CURRENT_TIMESTAMP(); END IF; IF NEW.SendingDateTime = \(aq0000-00-00 00:00:00\(aq THEN SET NEW.SendingDateTime = CURRENT_TIMESTAMP(); END IF; END;//

DELIMITER ;

NOTE: You can find the script in docs/sql/mysql.sql as well.

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 smsd-tables-history and then manually update Version field in gammu table.

AUTHOR

Michal Čihař <michal@cihar.com>

COPYRIGHT

2009-2015, Michal Čihař <michal@cihar.com>
Search for    or go to Top of page |  Section 7 |  Main Index


1.37.0 GAMMU-SMSD-MYSQL (7) February 03, 2016

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.