Guest User

Untitled

a guest
May 9th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import pymysql.cursors
  2. connection = pymysql.connect(host='localhost',
  3. user='bauhau93',
  4. password='hallo123',
  5. db='mr.tester',
  6. charset='utf8mb4',
  7. cursorclass=pymysql.cursors.DictCursor)
  8. print('CONNECTION SUCCESSFULL!')
  9.  
  10. try:
  11. with connection.cursor() as cursor:
  12. sql ="select * from telefonbuch"
  13. cursor.execute(sql)
  14. print("cursor.description:", cursor.description)
  15. print()
  16. for row in cursor:
  17. print(row)
  18. except:
  19. print("Abrafge war kacke")
  20.  
  21. finally:
  22. connection.close()
Add Comment
Please, Sign In to add comment