1 .TH "GAMMU-SMSD-SQL" "7" "December 21, 2011" "1.31.0" "Gammu"
3 gammu-smsd-sql \- gammu-smsd(1) backend using SQL abstraction layer to use any supported database as a message storage
5 .nr rst2man-indent-level 0
9 level \\n[rst2man-indent-level]
10 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
17 .\" .rstReportMargin pre:
19 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20 . nr rst2man-indent-level +1
21 .\" .rstReportMargin post:
25 .\" indent \\n[an-margin]
26 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27 .nr rst2man-indent-level -1
28 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
31 .\" Man page generated from reStructeredText.
35 SQL service stores all its data in database. It can use one of these SQL backends
36 (configuration option \fBDriver\fP in smsd section):
39 \fBnative_mysql\fP for \fIgammu\-smsd\-mysql\fP
41 \fBnative_pgsql\fP for \fIgammu\-smsd\-pgsql\fP
43 \fBodbc\fP for \fIgammu\-smsd\-odbc\fP
47 .B drivers supported by DBI for \fIgammu\-smsd\-dbi\fP, which include:
50 \fBsqlite3\fP \- for SQLite 3
52 \fBmysql\fP \- for MySQL
54 \fBpgsql\fP \- for PostgeSQL
56 \fBfreetds\fP \- for MS SQL Server or Sybase
60 .SH SQL CONNECTION PARAMETERS
62 Common for all backends:
65 \fBUser\fP \- user connecting to database
67 \fBPassword\fP \- password for connecting to database
69 \fBHost\fP \- database host or data source name
71 \fBDatabase\fP \- database name
73 \fBDriver\fP \- \fBnative_mysql\fP, \fBnative_pgsql\fP, \fBodbc\fP or DBI one
75 \fBSQL\fP \- SQL dialect to use
81 \fBDriversPath\fP \- path to DBI drivers
83 \fBDBDir\fP \- sqlite/sqlite3 directory with database
87 The variables are fully described in \fIgammurc\fP documentation.
91 Almost all queries are configurable. You can edit them in
92 \fB[sql]\fP section. There are several variables used in SQL
93 queries. We can separate them into three groups:
96 phone specific, which can be used in every query, see \fI\%Phone Specific Parameters\fP
98 SMS specific, which can be used in queries which works with SMS messages, see \fI\%SMS Specific Parameters\fP
100 query specific, which are numeric and are specific only for given query (or set of queries), see \fI\%Configurable queries\fP
102 .SS Phone Specific Parameters
112 client name (eg. Gammu 1.12.3)
114 .SS SMS Specific Parameters
124 delivery status on receiving or status error on sending
130 receiving datetime for received sms
136 SMS coding (ie 8bit or UnicodeNoCompression)
151 CreatorID of SMS (sending sms)
157 Sender number for received messages (insert to inbox or delivery notifications), destination otherwise.
158 .SH CONFIGURABLE QUERIES
160 All configurable queries can be set in \fB[sql]\fP section. Sequence of rows in selects are mandatory.
162 All default queries noted here are noted for MySQL. Actual time and time addition
163 are selected for default queries during initialization.
167 Deletes phone from database.
173 DELETE FROM phones WHERE IMEI = %I
180 Inserts phone to database.
186 INSERT INTO phones (IMEI, ID, Send, Receive, InsertIntoDB, TimeOut, Client, Battery, SignalStrength)
187 VALUES (%I, %P, %1, %2, NOW(), (NOW() + INTERVAL 10 SECOND) + 0, %N, \-1, \-1)
191 Query specific parameters:
195 enable send (yes or no) \- configuration option Send
198 enable receive (yes or no) \- configuration option Receive
203 .B save_inbox_sms_select
204 Select message for update delivery status.
210 SELECT ID, Status, SendingDateTime, DeliveryDateTime, SMSCNumber FROM sentitems
211 WHERE DeliveryDateTime IS NULL AND SenderID = %P AND TPMR = %t AND DestinationNumber = %R
217 .B save_inbox_sms_update_delivered
218 Update message delivery status if message was delivered.
224 UPDATE sentitems SET DeliveryDateTime = %C, Status = %1, StatusError = %e WHERE ID = %2 AND TPMR = %t
228 Query specific parameters:
232 delivery status returned by GSM network
240 .B save_inbox_sms_update
241 Update message if there is an delivery error.
247 UPDATE sentitems SET Status = %1, StatusError = %e WHERE ID = %2 AND TPMR = %t
251 Query specific parameters:
255 delivery status returned by GSM network
263 .B save_inbox_sms_insert
264 Insert received message.
270 INSERT INTO inbox (ReceivingDateTime, Text, SenderNumber, Coding, SMSCNumber, UDH,
271 Class, TextDecoded, RecipientID) VALUES (%d, %E, %R, %c, %F, %u, %x, %T, %P)
278 Update statistics after receiving message.
284 UPDATE phones SET Received = Received + 1 WHERE IMEI = %I
290 .B refresh_send_status
291 Update messages in outbox.
297 UPDATE outbox SET SendingTimeOut = (NOW() + INTERVAL locktime SECOND) + 0
298 WHERE ID = %1 AND (SendingTimeOut < NOW() OR SendingTimeOut IS NULL)
302 Query specific parameters:
311 .B find_outbox_sms_id
312 Find sms messages for sending.
318 SELECT ID, InsertIntoDB, SendingDateTime, SenderID FROM outbox
319 WHERE SendingDateTime < NOW() AND SendingTimeOut < NOW() AND
320 SendBefore >= CURTIME() AND SendAfter <= CURTIME() AND
321 ( SenderID is NULL OR SenderID = \(aq\(aq OR SenderID = %P ) ORDER BY InsertIntoDB ASC LIMIT %1
325 Query specific parameters:
329 limit of sms messages sended in one walk in loop
335 Select body of message.
341 SELECT Text, Coding, UDH, Class, TextDecoded, ID, DestinationNumber, MultiPart,
342 RelativeValidity, DeliveryReport, CreatorID FROM outbox WHERE ID=%1
346 Query specific parameters:
355 .B find_outbox_multipart
356 Select remaining parts of sms message.
362 SELECT Text, Coding, UDH, Class, TextDecoded, ID, SequencePosition
363 FROM outbox_multipart WHERE ID=%1 AND SequencePosition=%2
367 Query specific parameters:
374 Number of multipart message
380 Remove messages from outbox after threir successful send.
386 DELETE FROM outbox WHERE ID=%1
390 Query specific parameters:
399 .B delete_outbox_multipart
400 Remove messages from outbox_multipart after threir successful send.
406 DELETE FROM outbox_multipart WHERE ID=%1
410 Query specific parameters:
420 Create message (insert to outbox).
426 INSERT INTO outbox (CreatorID, SenderID, DeliveryReport, MultiPart,
427 InsertIntoDB, Text, DestinationNumber, RelativeValidity, Coding, UDH, Class,
428 TextDecoded) VALUES (%1, %P, %2, %3, NOW(), %E, %R, %V, %c, %u, %x, %T)
432 Query specific parameters:
439 delivery status report \- yes/default
442 multipart \- FALSE/TRUE
453 .B create_outbox_multipart
454 Create message remaining parts.
460 INSERT INTO outbox_multipart (SequencePosition, Text, Coding, UDH, Class,
461 TextDecoded, ID) VALUES (%4, %E, %c, %u, %x, %T, %5)
465 Query specific parameters:
472 delivery status report \- yes/default
475 multipart \- FALSE/TRUE
493 INSERT INTO sentitems (CreatorID,ID,SequencePosition,Status,SendingDateTime,
494 SMSCNumber, TPMR, SenderID,Text,DestinationNumber,Coding,UDH,Class,TextDecoded,
495 InsertIntoDB,RelativeValidity)
496 VALUES (%A, %1, %2, %3, NOW(), %F, %4, %P, %E, %R, %c, %u, %x, %T, %5, %V)
500 Query specific parameters:
507 part number (for multipart sms)
510 message state (SendingError, Error, SendingOK, SendingOKNoReport)
513 message reference (TPMR)
516 time when inserted in db
522 Update sent statistics after sending message.
528 UPDATE phones SET Sent= Sent + 1 WHERE IMEI = %I
534 .B refresh_phone_status
535 Update phone status (battery, signal).
541 UPDATE phones SET TimeOut= (NOW() + INTERVAL 10 SECOND) + 0,
542 Battery = %1, SignalStrength = %2 WHERE IMEI = %I
546 Query specific parameters:
557 Michal Čihař <michal@cihar.com>
559 2009-2011, Michal Čihař <michal@cihar.com>
560 .\" Generated by docutils manpage writer.