def from_crawler(cls, crawler):
settings = crawler.settings
kw = dict(
host=settings.get('MYSQL_HOST',' localhost'),
port=settings.get('MYSQL_PORT', 3306),
user=settings.get('MYSQL_USER', 'root'),
db=settings.get('MYSQL_DB', 'test'),
passwd=settings.get('MYSQL_PASSWD'),
charset='utf8',
use_unicode=True,
)
dbpool = adbapi.ConnectionPool ('MySQLdb', **kw)
return cls (dbpool)
评论列表
文章目录