-1
I’m using this code in the script:
#! /usr/bin/env python
# coding: utf8
import MySQLdb
db = MySQLdb.connect(host="xxx.xxx.x.xx", user="xxxxx", passwd="xxxxxxx", db="xxxxxxx")
cursor = db.cursor()
cursor.execute("SELECT DataConsulta, Dias, HoraConsulta, HoraSaida, nome, Consulta, centrodb.LocalConsulta.Descricao, Contato FROM centrodb.RegistoConsultas LEFT OUTER JOIN centrodb.LocalConsulta ON centrodb.LocalConsulta.Id = centrodb.RegistoConsultas.`Local` LEFT OUTER JOIN centrodb.UtentesCons ON centrodb.UtentesCons.codigoutente = centrodb.RegistoConsultas.Utente LEFT OUTER JOIN centrodb.DiasSemana ON centrodb.DiasSemana.Id = centrodb.RegistoConsultas.DiaSemana")
myresult = cursor.fetchall()
for linha in myresult:
DataConsulta = linha[0]
Dias = linha[1]
HoraConsulta = linha[2]
HoraSaida = linha[3]
nome = linha[4]
Consulta = linha[5]
Descricao = linha[6]
Contato = linha[7]
today = datetime.date.today()
data = today + datetime.timedelta(days=7)
if DataConsulta == data:
...
But when running the script I get this error:
The problem is the characters that exist in the database table with ~, how can I solve the problem?
is in ANSI. How I change in python IDLE 3.7?
– Bruno
I found that the database problem well, because one of the variables uses ~, how can I solve?
– Bruno
@Beginner, edit your question or open another one with more code details and connection to BD. It will be easier to help you.
– George Wurthmann
I edited the question with the code with the connection to the database and the loop. After if only has the API for sending the sms
– Bruno