Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement