Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: Mario Lopes
Added: Feb 19, 2018 10:44 AM
Views: 13
Tags: select update
Este código faz update e select com python
  1. import pymysql
  2. from bs4 import BeautifulSoup
  3. conn = pymysql.connect(host='localhost', port=3306, user='userdabasededados', passwd='passe', db='nomedadb')
  4. cur = conn.cursor()
  5. cur.execute('select * from impressoras where marca="SAMSUNG" and id<932')
  6. rows=cur.fetchall()
  7. for row in rows:
  8. #-------apanha os valores    
  9.     url="https://www.cpcdi.pt/Produtos/Referencia?referencia="+row[1]
  10.     buscaImagem(url,row[0])
  11.     print(url)
  12. # update sql table
  13. cur.execute ("update impressoras set imagem =%s where id =%s ",(aa,q))
  14.     conn.commit()
  15.     return