import pymysql
conn = pymysql.connect( host='mysql주소', user='python_user', port=23306, password='python1q2w3e4r!', db='python_test', charset='utf8mb4')
sql = 'insert into sample(memo) values(%s)'
vals = ('삼빠')
cur = conn.cursor()
cur.execute(sql, vals)
conn.commit()
# conn.close()
# for row in cur:
# print(row)
sql = 'select * from sample'
cur = conn.cursor( pymysql.cursors.DictCursor )
cur.execute( sql )
conn.commit()
rows = cur.fetchall()
for row in rows:
print( row['seq'], row['memo'] )
#여러 줄 출력
# for row in cur:
# print(row['seq'], row['memo'])
#한 줄 출력
# row = cur.fetchone()
# if row == None:
# print('검색결과없음')
# else:
# print(row)
#
# row = cur.fetchone()
# if row == None:
# print('검색결과없음')
# else:
# print(row)