mysql – Create a table with a delivery log

I have this script in python send automatic sms:

#! / usr / bin / env python
# - * - coding: utf-8 - * -
import MySQLdb
import pycurl
import into base64
import json
import date / time

db = MySQLdb.connect (host = xxx.xxx.x.xx, user = xxxxx, passwd = xxxxxx, db = xxxxxxx, charset = utf8)

cursor = db.cursor ()

cursor.execute ("SELECT Data Query, Days, QueryTime, Timeout, Name, Query, Centrodb.LocalConsult.Description, Contact DE centrodb.RegistryConsults LEFT OUTER JOIN centrodb.LocalConsulta ON centrodb.LocalConsulta.Id = centrodb .LocalConsulta ON OUTSIDE JOINT centrodb.UtentsCons ON centrodb.UtentsCons.codigente = centrodb.RegistoConsultadas.Utente LEFT OUTER JOIN centrodb.DaysSemana ON centrodb.DaysSemana.Id = centrodb.RegistoConsultasDiaSemana)

myresult = cursor.fetchall ()

for the line in myresult:
QueryDate = row[0]
 Days = line[1]
 QueryTime = row[2]
 HourSaida = line[3]
 name = line[4]
 Query = line[5]
 Description = line[6]
 Contact = line[7]

 today = datetime.date.today ()
date = today + date / time.timedelta (days = 7)

if DataConsulta == data:
if __name__ == "__main__":
url = "https://dashboard.360nrs.com/api/rest/sms"
usrPass = "xxxxxx: xxxxxx"
data = json.dumps ({
you "to":[Contato],
u "of": u "xxxxxxx",
u "message": u "LAR.We remember that the user {} has a {} request on the day {} to {} on {}.
name, request, date of request, time of request, description),
u "encoding": u "gsm-pt",
"parts": "2"
})
b64Val = base64.b64encode (usrPass)
headers =["Accept:Application/json","Authorization:Basic %s"%b64Val]
    c = pycurl.Curl ()
c.setopt (pycurl.URL, url)
c.setopt (pycurl.HTTPHEADER, headers)
c.setopt (pycurl.POST, 1)
c.setopt (pycurl.POSTFIELDS, data)
c.setopt (pycurl.SSL_VERIFYHOST, 0)
c.setopt (pycurl.SSL_VERIFYPEER, 0)
c.perform ()
http_code = c.getinfo (pycurl.HTTP_CODE)
print (http_code)

Now, every time I send a sms to a table in the database, it was meant to be sent successfully or not, type a log system.