Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import pymysql
  2.  
  3. hostname = '104.196.69.254'
  4. username = 'aquaponics'
  5. password = 'duck'
  6. database = 'Controller_1'
  7.  
  8. connection = pymysql.connect(host=hostname, user=username, db=database, charset='utf8', cursorclass=pymysql.cursors.DictCursor)
  9.  
  10. try:
  11.     with connection.cursor() as cursor:
  12.         sql = "INSERT INTO 'test' ('name', 'age') VALUES (%s, %s)"
  13.         cursor.execute(sql, ('coleman', 17))
  14.         connection.commit()
  15. finally:
  16.     connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement