I have a table in a database with columns, dept name, name, id, date,day, time, mobile number. Each column is having its own value. I want to fetch the above data from the database and send an sms extracting details from the database table The sms format is :the attendance of name on date, day is:time (send to no in database)
we found the code for sending sms to text file and its working fine through sim 300. but we want it to send to nos. stored in database the code we designed for text file is as follows
import serial
import MySQLdb as mdb
import _mysql as m
def sendMsg(s,num,text):
cr = chr(13)
s.write('at' + cr)
s.write('AT+CMGF=1'+cr)
s.write('AT+CMGS="' + num + '"' + cr)
s.write(text)
s.write(cz)
s.write(cr)
print "Msg Sent"
#print s.readline()
#print s.readline()
#def sendComm(s,string):
# s.write(string + chr(13))
# print s.readline()
# print string,'--->',s.readline()
s = serial.Serial(19)
cz = chr(26)
s.setBaudrate(9600)
with open('palav.txt','r') as f:
lines = f.readlines()
for line in lines:
name,number,att = line.split(',')
att = att.strip()
text = "Your ward %s is having attendance %s%%" % (name,att)
print text
sendMsg(s,number,text)
print "Message Sent"
s.close()
please help us to send it through database username:root,password:"" database :attend