mysqlclient

1 개요[ | ]

mysqlclient
mysqlclient-python
PyMySQL/mysqlclient-python
  • 파이썬 mysql 드라이버
  • MySQLdb1의 포크
  • OS 패키지에 의존성이 있다. ★
  • django에서 권장하는 mysql 드라이버 ★

2 설치[ | ]

Debian / Ubuntu
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
pip install mysqlclient
Red Hat / CentOS
sudo yum install python3-devel mysql-devel
pip install mysqlclient

3 예제[ | ]

from MySQLdb import _mysql
db=_mysql.connect(host="localhost",user="joebob",passwd="moonpie",db="thangs")
db.query("""SELECT spam, eggs, sausage FROM breakfast
         WHERE price < 5""")
r=db.store_result()
print( r.fetch_row() )
# (('3','2','0'),)
import MySQLdb
db=MySQLdb.connect(passwd="moonpie",db="thangs")
c=db.cursor()
max_price=5
c.execute("""SELECT spam, eggs, sausage FROM breakfast
          WHERE price < %s""", (max_price,))
print( c.fetchone() )
# (3L, 2L, 0L)

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}