The home computer uses the Linux operating system, the recently collected data needs to be stored to MySQL, originally uses the web.py the time to use the MySQL is all normal, results now directly uses the MYSQLDB to connect the database the exception:
/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)
Look at the prompt should be Linux system permissions problem, and on the XP computer verified that the connection to the MySQL Python code itself is not a problem, the code is as follows:
#coding =utf-8import mysqldbtry:conn = mysqldb.connect (host = ' 127.0.0.1 ', user = ' root ', passwd = ', db = ' sys ') c ur = conn.cursor () cur.execute ("INSERT into book (description) Select ' Test ' from dual where NOT exists (select 1 from b ook where id = 7) "Conn.commit () Cur.close () conn.close () except Mysqldb.error, E:print ' MySQL Error:%d%s ' % (E.arg[0], e.arg[1])
Initially it is easy to assume that the permissions are insufficient, follow the prompts in the Linux terminal will/home/huayuan/.python-eggs increase read and Write permissions:
chmod A+rw/home/huayuan/.python-eggs
The problem is still, and then after repeated search, finally found the answer, it is not to increase permissions, but to reduce some of the permissions, the final valid answer is as follows:
chmod g-wx, O-wx/home/huayuan/.python-eggs
This article is from the "Free Self" blog, please be sure to keep this source http://hhuayuan.blog.51cto.com/1630327/1574716
Linux python connection MySQL exception