반응형
PyMySQL은 Python에서 MySQL사용을 도와주는 순수 Python MySQL client library이다.
설치 조건:
설치:
Package is uploaded on PyPI.
You can install it with pip:
$ python3 -m pip install PyMySQL
관련 문서:
Documentation is available online: https://pymysql.readthedocs.io/
For support, please refer to the StackOverflow.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import pymysql connection = pymysql.connect(host = '127.0.0.1', port = 3306, user = 'root', password = '1234', db = 'shopdb', charset = 'utf8') # Representation of a socket with a mysql server. The proper way to get an instance of this class is to call connect(). # Establish a connection to the MySQL database. cursor = connection.cursor() # Create a new cursor to execute queries with sql = "select * from membertbl" cursor.execute(sql) # Execute a query rows = cursor.fetchall() # Fetch all the rows for member in rows: print(member) connection.close() # Closing a cursor just exhausts all remaining data. | cs |
반응형
'Python' 카테고리의 다른 글
Pillow 이미지 서치(Image Search) 1 (0) | 2018.11.30 |
---|---|
pywin32 Windows Extensions for Python 2 (0) | 2018.11.27 |
pywin32 Windows Extensions for Python 1 (0) | 2018.11.27 |
Pillow 화면 변화 감지(Pixel Checksum) 2 (0) | 2018.11.21 |
Pillow 화면 변화 감지(Pixel Checksum) 1 (0) | 2018.11.20 |