Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import pymysql.cursors
- def transaction():
- File = open("/tmp/test","a+")
- connection = pymysql.connect(host='172.18.0.1',
- user='root',
- password='123',
- db='sakila')
- File.write("Gnoll\n")
- try:
- with connection.cursor() as cursor:
- rental = "INSERT INTO rental(inventory_id,customer_id,staff_id) VALUES ({},{},{})".format(997,1,1)
- # payment ="INSERT INTO payment(customer_id, staff_id, rental_id, amount) VALUES(1, 1, LAST_INSERT_ID(), 4)"
- cursor.execute(rental)
- # cursor.execute(payment)
- connection.commit()
- cursor.close()
- except Exception as e:
- File.write(e.message)
- finally:
- connection.close()
- File.close()
- return "Dupa Closed"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement