mysql python library_Python中使用MySQL的问题

[mysql的数据表是这样的: +----+------+------+ | id | name | age | +----+------+------+ | 1 | cxx | 25 | +----+------+------+ 我的python代码: {代码...} 上半部分

第一步:安装MySQL-python-1.2.2.tar

python setup.py build python setup.py intstall

第二步:可能遇到的错误

1、libmysqlclient.so.16: cannot open shared object file: No such file or directory

需要安装新的包mysqlclient16-5.1.30-1.el5.remi.i386

或者通过ln -s设置链接

2、 在build的时候需要按照setuptools-0.6b1-py2.4.egg包

% wget -q http://peak.telecommunity.com/dist/ez_setup.py % python ez_setup.py Downloading http://cheeseshop.python.org/packages/2.4/s/ setuptools/setuptools-0.6b1-py2.4.egg#md5=b79a8a403e4502fbb85ee3f1941735cb Processing setuptools-0.6b1-py2.4.egg creating /sw/lib/python2.4/site-packages/setuptools-0.6b1-py2.4.egg Extracting setuptools-0.6b1-py2.4.egg to /sw/lib/python2.4/site-packages Removing setuptools 0.6a11 from easy-install.pth file Adding setuptools 0.6b1 to easy-install.pth file Installing easy_install script to /sw/bin Installing easy_install-2.4 script to /sw/bin Installed /sw/lib/python2.4/site-packages/setuptools-0.6b1-py2.4.egg Processing dependencies for setuptools

[ 缘由   近期在折腾一个小东西须要抓取网上的页面。然后进行解析。将结果放到数据库中。   了解到Python在这方面有优势,便选用之。   由于我有台server上面安装

这个按照需要上网,需要设置网络环境ip地址+DNS。

3  EnvironmentError: mysql_config not found

MySQL-python-1.2.2]# vi setup_posix.py 26 mysql_config.path = "/usr/local/mysql/bin/mysql_config" 将26行改为mysql_config的真是路径 再次执行python setup.py build;python setup.py install 就OK了

4 /usr/bin/ld: cannot find -lmysqlclient_r

解决方法一(已经测试通过)

执行以下命令: echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf(我的环境是centos 5) ldconfig,执行以后还是提示以上错误。 ———————– 后来看来一下README,原文在下面 ——————- threadsafe thread-safe client library (libmysqlclient_r) if True (default); otherwise use non-thread-safe (libmysqlclient). You should always use the thread-safe library if you have the option; otherwise you *may* have problems. ——————————— 得知得修改site.cfg,将thread-safe设为false,一切OK! python setup.py install

解决方法二(没有测试)A thread-safe client library (libmysqlclient_r) will be created automatically during the compilation of MySQL  if the configure command contains the option "--enable-thread-safe-client".

[缘由最近在折腾一个小东西需要抓取网上的页面,然后进行解析,将结果放到数据库中。了解到Python在这方面有优势,便选用之。因为我有台服务器上面安装有mysql,自然使用之

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值