Permalink
Browse files

Select messages to be sent from DB and send it to particular number

  • Loading branch information...
1 parent 506df6c commit 4dcd6154ddbfa72994d0df1e78c1eb7f74aee574 Karthik Subramanian committed Jun 14, 2010
Showing with 36 additions and 0 deletions.
  1. +36 −0 smsdb.py
View
@@ -0,0 +1,36 @@
+import MySQLdb
+
+db = MySQLdb.connect(host="localhost", port=3306, user="root", passwd="ssn", db="smsmail")
+
+cursor=db.cursor()
+
+
+import time
+from pygsm import GsmModem
+
+gsm = GsmModem(
+ port="/dev/ttyUSB0",
+ logger=GsmModem.debug_logger).boot()
+
+
+cursor.execute('select * from mails where sent=0')
+data=cursor.fetchall()
+
+msg=[]
+
+
+i=0
+
+for row in data:
+ mess=str(row[2]+'\n'+row[3])
+ ids=row[0]
+ msg.append((ids,mess))
+
+ i+=1
+
+for ids,mess in msg:
+ print ids,mess
+ gsm.send_sms('+919840756217',mess)
+ cursor.execute('update mails set sent=1 where mailid=%s',ids)
+
+#print mailid,email,fromid,subject,mobile,idm

0 comments on commit 4dcd615

Please sign in to comment.