반응형 2019/112 python 데이터베이스 select, insert 조회 삽입 python으로 mysql 데이터베이스 select, insert 하기 python 데이터베이스 조회 select import pymysql conn = pymysql.connect( host='127.0.0.1', port=3306, user='username', password='password!!*', db='db-name', charset='utf8' ) try: with conn.cursor() as cursor: sql = "select * from table_name" cursor.execute(sql) result = cursor.fetchall() finally: conn.close() python 데이터베이스 삽입 insert import pymysql conn = pymysql.con.. 2019. 11. 29. python url 문자열 변환 url 한글 인코딩 디코딩 url 에 한글이 포함될 경우 오류가 나는 경우가 있다. 이때 한글을 url 인코더로 바꿔서 입력해야 한다. urllib 의 quote 와 unquote 사용 quote() : 한글 -> url unquote() : url -> 한글 import urllib urllib.parse.quote("안녕하세요") >>> '%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94' urllib.parse.unquote("%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94") >>> '안녕하세요' 2019. 11. 29. 이전 1 다음 반응형