0
Any example of a Python Post method service? I don’t know how to do this with the database connection. I know how to do Get and I’ll leave an example below.
@route('/dadosBloqueios', method = "GET")
def dadosBloqueios():
response.content_type = 'application/json;charset=utf-8'
cnx = mysql.connector.connect(host='*', database='*',
user='*', password='*')
cnx_cursor1 = cnx.cursor(dictionary=True)
dadosBloqueios = { } #lista de dados
####
sql1 = "SELECT count(*) FROM DB.Utilizadores where Bloqueado = 1;"
cnx_cursor1.execute(sql1)
l = cnx_cursor1.fetchone()
while l is not None: #vai ler tudo ate o l ser vazio
dadosBloqueios["Número total de utilizadores bloqueados"] = l["count(*)"]
l = cnx_cursor1.fetchone()
cnx.close()
return json.dumps(dadosBloqueios)
And how does the database connection work? Have an example?
– user101221