标签:sql数据库 str pretty x86 sql nbsp .so tle figure
1:Python安装pyodbc:pip install pyodbc
2:安装unixODBC-2.3.4.tar.gz
3:下载基于python的MySQL驱动(mysql-connector-odbc-5.3.6-osx10.11-x86-64bit)
4:编写配置文件
vim /usr/local/etc/odbcinst.ini
[MySQL51]
Description=MySQL 5.1.8 driver for Unix
Driver=你的路径/mysql-connector-odbc-5.3.6-osx10.11-x86-64bit/lib/libmyodbc5a.so
5:使用pyodbc进行连接
import pyodbc
conn_info = (‘Driver{MySQL51};Server=%s;Port=%s;Database=%s;User=%s; Password=%s;Option=3;‘%(host, port, database, user,password))
mysql_conn = pyodbc.connect(conn_info)
mysql_cur = self.mysql_conn.cursor()
标签:sql数据库 str pretty x86 sql nbsp .so tle figure
原文地址:http://www.cnblogs.com/ruiy/p/7155159.html