Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import pymysql.cursors
  4. def transaction():
  5. File = open("/tmp/test","a+")
  6. connection = pymysql.connect(host='172.18.0.1',
  7. user='root',
  8. password='123',
  9. db='sakila')
  10.  
  11. File.write("Gnoll\n")
  12.  
  13. try:
  14. with connection.cursor() as cursor:
  15. rental = "INSERT INTO rental(inventory_id,customer_id,staff_id) VALUES ({},{},{})".format(997,1,1)
  16. # payment ="INSERT INTO payment(customer_id, staff_id, rental_id, amount) VALUES(1, 1, LAST_INSERT_ID(), 4)"
  17. cursor.execute(rental)
  18. # cursor.execute(payment)
  19. connection.commit()
  20. cursor.close()
  21. except Exception as e:
  22. File.write(e.message)
  23. finally:
  24. connection.close()
  25.  
  26. File.close()
  27. return "Dupa Closed"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement