Guest User

Untitled

a guest
Sep 9th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import mysql.connector
  2.  
  3. def main():
  4. conn = mysql.connector.connect(user='root',
  5. password='',
  6. host='127.0.0.1',
  7. database='isubata')
  8.  
  9. cur = conn.cursor()
  10. sql = "select name,data from image"
  11. cur.execute(sql)
  12. row = cur.fetchall()
  13.  
  14. fname = row[0::2]
  15. fdata = row[1::2]
  16. num_of_file = len(fdata)
  17.  
  18. for i in range(num_of_file):
  19. f = open(fname[i], 'wb')
  20. f.write(fdata[i])
  21. f.close()
  22.  
  23.  
  24. if __name__ == '__main__':
  25. main()
Add Comment
Please, Sign In to add comment