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>]

相关文章
相关标签/搜索