123456789101112131415161718192021222324252627282930 |
- # -*- coding: utf-8 -*-
- __author__ = 'cwh'
- # 使用DBUtils连接数据库的方法,比twisted简单很多。
- import MySQLdb
- from DBUtils.PooledDB import PooledDB
- #api.1473.cn在数据库中的站点地图数据
- class ApiSitemapData(object):
- def __init__(self):
- self.pool = PooledDB(MySQLdb,5,host='10.20.5.88',user='root',passwd='usestudio-1',db='US_Crawler',port=14062,charset="utf8")
- def selectData(self):
- conn = self.pool.connection()
- cur = conn.cursor()
- # 调用存储过程示例
- #cur.callproc('InsertAPIData', ('1000','张三'))
- # 存储过程传递参数
- #cur.callproc('InsertAPIData', (item['name'],item['name']))
- cur.callproc('SiteMapData',())
- _tuples= cur._cursor._rows
- #for t in _tuples:
- # print(t)
- # print out the result
- cur.close()
- conn.commit()
- conn.close()
- return _tuples
|