Advertisement
Guest User

python

a guest
Jan 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import pymysql.cursors
  2. host_name = input("Enter host name : ")
  3. user = input('Enter username for database : ')
  4. psw = input('Enter password for database : ')
  5. db_name = input("Enter database name : ")
  6. task1 = input("Do you want to insert data")
  7.  
  8. connection = pymysql.connect(host= host_name,
  9. user= user,
  10. password= psw,
  11. db= db_name,
  12. charset='utf8mb4',
  13. cursorclass=pymysql.cursors.DictCursor)
  14. table_name = input("Enter table name : ")
  15.  
  16. with connection.cursor() as cursor:
  17. sql = "SELECT '*' FROM 'users';"
  18. cursor.execute(sql)
  19. result = cursor.fetchall()
  20. print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement