Guest User

Untitled

a guest
Mar 29th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import pymysql.cursors
  2. import xlwt
  3.  
  4.  
  5. connection = pymysql.connect(host='localhost',user='root',password='',db='test',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor)
  6.  
  7. print ("Подключено!!!")
  8.  
  9. try:
  10. with connection.cursor() as cursor:
  11. sql="SELECT prod_name,prod_price From products"
  12. cursor.execute(sql)
  13. print ("cursor.description: ", cursor.description)
  14. print()
  15. for row in cursor:
  16. print (row)
  17.  
  18.  
  19. finally:
  20. connection.close()
Add Comment
Please, Sign In to add comment