Advertisement
Guest User

Untitled

a guest
Apr 6th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. import pymysql
  2. from readTask import tampil
  3. connection = pymysql.connect(
  4.     host='localhost',
  5.     user='root',
  6.     password='',
  7.     db='buku',
  8. )
  9.  
  10. tampil()
  11. menu = input('pilih id buku : ')
  12. jdl = input('update title buku : ')
  13. cat = input('update category buku : ')
  14. hrg = int(input('update harga buku : '))
  15. try:
  16.     with connection.cursor() as cursor:
  17.         sql = "UPDATE buku SET `title`, `category`, `harga` WHERE `id_buku` ="+str(menu)
  18.         try:
  19.             cursor.execute(sql, (jdl, cat, hrg, menu))
  20.  
  21.             print("Successfully Updated...")
  22.         except pymysql.Error as e:
  23.             print("Oops! Something wrong", e)
  24.  
  25.     connection.commit()
  26. finally:
  27.     connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement