connection = pymysql.connect(host='host', port=3306,
db='db', user='user',
passwd='pw', charset='utf8')
cursor = connection.cursor()
connection.ping(reconnect=True) # try reconnect
sql = f"REPLACE INTO item (name,price) VALUES (%s,%s)"
cursor.execute(sql, ("name","100"))
connection.commit()
connection.ping(reconnect=True)를 추가한다
반응형
'python > python' 카테고리의 다른 글
anaconda 파이썬 64bit 32bit 설치 (0) | 2018.12.01 |
---|