1 .TH "GAMMU-SMSD-SQL" "7" "January 19, 2011" "1.29.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.
34 SQL service stores all its data in database. It can use one of these SQL backends
35 (configuration option \fBDriver\fP in smsd section):
39 \fBnative_mysql\fP for \fIgammu\-smsd\-mysql\fP
42 \fBnative_pgsql\fP for \fIgammu\-smsd\-pgsql\fP
46 .B drivers supported by DBI for \fIgammu\-smsd\-dbi\fP, which include:
50 \fBsqlite3\fP \- for SQLite 3
53 \fBmysql\fP \- for MySQL
56 \fBpgsql\fP \- for PostgeSQL
59 \fBfreetds\fP \- for MS SQL Server or Sybase
63 .SH SQL CONNECTION PARAMETERS
65 Common for all backends:
69 \fBUser\fP \- user connecting to database
72 \fBPassword\fP \- password for connecting to database
75 \fBHost\fP \- database host
78 \fBDatabase\fP \- database name
81 \fBDriver\fP \- \fBnative_mysql\fP, \fBnative_pgsql\fP or DBI one
88 \fBDriversPath\fP \- path to DBI drivers
91 \fBDBDir\fP \- sqlite/sqlite3 directory with database
95 The variables are fully described in \fIgammurc\fP documentation.
99 Almost all queries are configurable. You can edit them in
100 \fB[sql]\fP section. There are several variables used in SQL
101 queries. We can separate them into three groups:
105 phone specific, which can be used in every query, see \fI\%Phone Specific Parameters\fP
108 SMS specific, which can be used in queries which works with SMS messages, see \fI\%SMS Specific Parameters\fP
111 query specific, which are numeric and are specific only for given query (or set of queries), see \fI\%Configurable queries\fP
113 .SS Phone Specific Parameters
126 client name (eg. Gammu 1.12.3)
128 .SS SMS Specific Parameters
141 delivery status on receiving or status error on sending
149 receiving datetime for received sms
157 SMS coding (ie 8bit or UnicodeNoCompression)
177 CreatorID of SMS (sending sms)
185 Sender number for received messages (insert to inbox or delivery notifications), destination otherwise.
186 .SH CONFIGURABLE QUERIES
188 All configurable queries can be set in \fB[sql]\fP section. Sequence of rows in selects are mandatory.
190 All default queries noted here are noted for MySQL. Actual time and time addition
191 are selected for default queries during initialization.
196 Deletes phone from database.
202 DELETE FROM phones WHERE IMEI = %I
210 Inserts phone to database.
216 INSERT INTO phones (IMEI, ID, Send, Receive, InsertIntoDB, TimeOut, Client, Battery, Signal)
217 VALUES (%I, %P, %1, %2, NOW(), (NOW() + INTERVAL 10 SECOND) + 0, %N, \-1, \-1)
221 Query specific parameters:
226 enable send (yes or no) \- configuration option Send
230 enable receive (yes or no) \- configuration option Receive
235 .B save_inbox_sms_select
237 Select message for update delivery status.
243 SELECT ID, Status, SendingDateTime, DeliveryDateTime, SMSCNumber FROM sentitems
244 WHERE DeliveryDateTime IS NULL AND SenderID = %P AND TPMR = %t AND DestinationNumber = %R
250 .B save_inbox_sms_update_delivered
252 Update message delivery status if message was delivered.
258 UPDATE sentitems SET DeliveryDateTime = %C, Status = %1, StatusError = %e WHERE ID = %2 AND TPMR = %t
262 Query specific parameters:
267 delivery status returned by GSM network
276 .B save_inbox_sms_update
278 Update message if there is an delivery error.
284 UPDATE sentitems SET Status = %1, StatusError = %e WHERE ID = %2 AND TPMR = %t
288 Query specific parameters:
293 delivery status returned by GSM network
302 .B save_inbox_sms_insert
304 Insert received message.
310 INSERT INTO inbox (ReceivingDateTime, Text, SenderNumber, Coding, SMSCNumber, UDH,
311 Class, TextDecoded, RecipientID) VALUES (%d, %E, %R, %c, %F, %u, %x, %T, %P)
319 Update statistics after receiving message.
325 UPDATE phones SET Received = Received + 1 WHERE IMEI = %I
331 .B refresh_send_status
333 Update messages in outbox.
339 UPDATE outbox SET SendingTimeOut = (NOW() + INTERVAL locktime SECOND) + 0
340 WHERE ID = %1 AND (SendingTimeOut < NOW() OR SendingTimeOut IS NULL)
344 Query specific parameters:
354 .B find_outbox_sms_id
356 Find sms messages for sending.
362 SELECT ID, InsertIntoDB, SendingDateTime, SenderID FROM outbox
363 WHERE SendingDateTime < NOW() AND SendingTimeOut < NOW() AND
364 ( SenderID is NULL OR SenderID = \(aq\(aq OR SenderID = %P ) ORDER BY InsertIntoDB ASC LIMIT %1
368 Query specific parameters:
373 limit of sms messages sended in one walk in loop
380 Select body of message.
386 SELECT Text, Coding, UDH, Class, TextDecoded, ID, DestinationNumber, MultiPart,
387 RelativeValidity, DeliveryReport, CreatorID FROM outbox WHERE ID=%1
391 Query specific parameters:
401 .B find_outbox_multipart
403 Select remaining parts of sms message.
409 SELECT Text, Coding, UDH, Class, TextDecoded, ID, SequencePosition
410 FROM outbox_multipart WHERE ID=%1 AND SequencePosition=%2
414 Query specific parameters:
423 Number of multipart message
430 Remove messages from outbox after threir successful send.
436 DELETE FROM outbox WHERE ID=%1
440 Query specific parameters:
450 .B delete_outbox_multipart
452 Remove messages from outbox_multipart after threir successful send.
458 DELETE FROM outbox_multipart WHERE ID=%1
462 Query specific parameters:
474 Create message (insert to outbox).
480 INSERT INTO outbox (CreatorID, SenderID, DeliveryReport, MultiPart,
481 InsertIntoDB, Text, DestinationNumber, RelativeValidity, Coding, UDH, Class,
482 TextDecoded) VALUES (%1, %P, %2, %3, NOW(), %E, %R, %V, %c, %u, %x, %T)
486 Query specific parameters:
495 delivery status report \- yes/default
499 multipart \- FALSE/TRUE
512 .B create_outbox_multipart
514 Create message remaining parts.
520 INSERT INTO outbox_multipart (SequencePosition, Text, Coding, UDH, Class,
521 TextDecoded, ID) VALUES (%4, %E, %c, %u, %x, %T, %5)
525 Query specific parameters:
534 delivery status report \- yes/default
538 multipart \- FALSE/TRUE
559 INSERT INTO sentitems (CreatorID,ID,SequencePosition,Status,SendingDateTime,
560 SMSCNumber, TPMR, SenderID,Text,DestinationNumber,Coding,UDH,Class,TextDecoded,
561 InsertIntoDB,RelativeValidity)
562 VALUES (%A, %1, %2, %3, NOW(), %F, %4, %P, %E, %R, %c, %u, %x, %T, %5, %V)
566 Query specific parameters:
575 part number (for multipart sms)
579 message state (SendingError, Error, SendingOK, SendingOKNoReport)
583 message reference (TPMR)
587 time when inserted in db
594 Update sent statistics after sending message.
600 UPDATE phones SET Sent= Sent + 1 WHERE IMEI = %I
606 .B refresh_phone_status
608 Update phone status (battery, signal).
614 UPDATE phones SET TimeOut= (NOW() + INTERVAL 10 SECOND) + 0,
615 Battery = %1, Signal = %2 WHERE IMEI = %I
619 Query specific parameters:
632 Michal Čihař <michal@cihar.com>
634 2009-2011, Michal Čihař <michal@cihar.com>
635 .\" Generated by docutils manpage writer.