python
                
              python -- mac 에서 mysql 연동하기
                자유프로그램
                 2015. 11. 9. 11:10
              
              
                    
        반응형
    
    
    
  python -- mysql 연동하기
환경 : client -- 맥 요세미티, python 2.7.8, PyMySQL 0.6.7
mysql db server -- ubuntu 14.04 LTS 64bit Server, Mysql 5.5
참고 : https://pypi.python.org/pypi/PyMySQL/0.6.7
** PyMySQL 설치하기
$ pip install PyMySQL
** Mysql 연동하여 사용하기
>>> import pymysql.cursors
>>> conn = pymysql.connect(host='192.168.10.36',user='tester',password='tester1234',db='myschool')
>>> cur = conn.cursor()
>>> sql = 'select 1234'
>>> cur.execute(sql)
1
>>> res = cur.fetchall()
>>> res
((1234,),)
>>>
반응형