Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. if os.path.isfile('\offline.csv'):
  2.  
  3. try:
  4. csv = csv.reader(open('\offline.csv', encoding='utf-8'))
  5. for row in csv:
  6. conn = connect()
  7. cursor = conn.cursor()
  8. query = "INSERT INTO maquina(processador, mb_fabricante, mb_modelo, mb_num_serie, sis_hostname, sis_versao_sistema, sis_data_instalacao, rede_ipv4, rede_macaddress, rede_srv_dns, memoria_ram, total_hd, nome_tecnico)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);"
  9. cursor.execute(query, row)
  10. conn.commit()
  11. print('sucesso csv')
  12. cursor.close()
  13. conn.close()
  14. except Exception as erro:
  15. print('erro csv', erro)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement