Last active
October 14, 2016 17:00
-
-
Save bongbongco/a9560933b2af5949ab2097955b6a31e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymysql | |
# MySQL Connection 연결 | |
conn = pymysql.connect(host='localhost', user='tester', password='', | |
db='testdb', charset='utf8') | |
# Connection 으로부터 Cursor 생성 | |
curs = conn.cursor() | |
# SQL문 실행 | |
sql = "select * from customer" | |
curs.execute(sql) | |
# 데이타 Fetch | |
rows = curs.fetchall() | |
print(rows) # 전체 rows | |
# print(rows[0]) # 첫번째 row: (1, '김정수', 1, '서울') | |
# print(rows[1]) # 두번째 row: (2, '강수정', 2, '서울') | |
# Connection 닫기 | |
conn.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment