Guest User

Untitled

a guest
Jan 22nd, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import mysql.connector as myc
  2.  
  3. # conexão MySQL
  4. conMySQL = myc.connect (host = 'localhost',user = 'root',password = 'mysql',database = 'teste')
  5.  
  6. cursorMySQL = conMySQL.cursor()
  7. sqlMySQL = """SELECT
  8. f.fid,
  9. f.uri,
  10. n.nid AS FK_REGISTRO_VIRTUAL
  11. FROM field_data_field_anexos a
  12. JOIN node n ON a.entity_id = n.nid
  13. JOIN file_managed f ON a.field_anexos_fid = f.fid
  14. WHERE n.`type` = 'registro_virtual' and f.fid = 76881;"""
  15. cursorMySQL.execute(sqlMySQL)
  16.  
  17. result = cursorMySQL.fetchall()
  18. for fid, uri, nid in result:
  19. print(fid ,'-', uri.decode('utf8'), '-', nid)
  20.  
  21. cursorMySQL.close()
  22. conMySQL.close()
Add Comment
Please, Sign In to add comment