Mac OS X 下安裝 python-mysql 支持 SQLAlchemy

Mac OS X 下安裝 python-mysql html

這裏有一個坑 作個記號python

https://www.zhihu.com/question/30963225mysql

 

方法一git

嗯,也是被坑了個2小時。
解決方法:github

  1. 先把以前裝的卸載乾淨:
    pip uninstall mysql-python
    brew uninstall mysql-connector-c
  2. 如今設置下mysql_config路徑:
    首先修改系統配置文件vim ~/.bash_profile或者有些人是 ~/.profile,export PATH=$PATH:/Applications/MAMP/Library/bin
    這裏/Applications/MAMP/Library/bin是MAMP的mysql配置文件路徑
  3. 安裝
    brew install mysql-connector-c
    pip install mysql-python
  4. 我是這麼搞定的



做者:姜朋飛
連接:https://www.zhihu.com/question/30963225/answer/88839392
來源:知乎
著做權歸做者全部,轉載請聯繫做者得到受權。sql

 

 

方法二  換 PyMYSQL 驅動 SQLAlchemy官方支持vim

0.文檔
MySQL — SQLAlchemy 1.0 Documentationbash

http://docs.sqlalchemy.org/en/rel_1_0/dialects/mysql.html#module-sqlalchemy.dialects.mysql.pymysqlhtm

1.要選好庫
不要用python-mysql, 用PyMySQL sqlalchemy

https://github.com/PyMySQL/PyMySQL

2.要改鏈接字符 mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]

相關文章
相關標籤/搜索