Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql
- hostname = '104.196.69.254'
- username = 'aquaponics'
- password = 'duck'
- database = 'Controller_1'
- connection = pymysql.connect(host=hostname, user=username, db=database, charset='utf8', cursorclass=pymysql.cursors.DictCursor)
- try:
- with connection.cursor() as cursor:
- sql = "INSERT INTO 'test' ('name', 'age') VALUES (%s, %s)"
- cursor.execute(sql, ('coleman', 17))
- connection.commit()
- finally:
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement