家里的电脑使用Linux操作系统,最近采集的数据需要存储到MySQL,本来使用web.py的时候使用MySQL是一切正常的,结果现在直接使用MySQLdb连接数据库时异常:
/usr/lib/python2.7/dist-packages/pkg_resources.py:1031: UserWarning: /home/huayuan/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
看提示应该是Linux系统权限问题,而且在XP电脑上验证过,连接MySQL的Python代码本身是没有问题的,代码如下:
#coding=utf-8
import MySQLdb
try:
conn = MySQLdb.connect(host = '127.0.0.1', user = 'root', passwd = '', db = 'sys')
cur = conn.cursor()
cur.execute("insert into book(description) select 'test' from dual where not exists (select 1 from book where id = 7)")