[Python]操作Mysql
安装:
Ubuntu下,直接
sudo apt-get install python-mysqldb
在Python代码中,需要import Mysql类库
from MySQLdb import *
连接并运行SQL语句
cn = Connection('localhost', 'root', '')
cn.select_db('yphp')
cur = cn.cursor()
cur.execute('SET NAMES UTF8')
cur.execute('select id,url,content from yphp_spider_url where checked=0 limit 0,1')
rs = cur.fetchone()
print rs