Skip to content
This repository has been archived by the owner on Apr 21, 2018. It is now read-only.

Latest commit

 

History

History
40 lines (29 loc) · 740 Bytes

db.rst

File metadata and controls

40 lines (29 loc) · 740 Bytes

DB

生成 DB 示例以供其他模块使用

用法

生成数据库实例

from taobao_crawler.utils.db import DB
db_config = {'db_user': '',  # 数据库用户名
             'db_pass': '',  # 数据库密码
             'db_host': 'localhost',  # 数据库地址
             'db_port': 27017,  # 数据库端口
             'db_name': 'taobao'}  # 数据库 collection 名称
mongo = DB(db_config)

与其他模块搭配使用

rate_crawler = RateCrawler(mongo.db)

关闭数据库连接

mongo.close()

类属性

.. autoclass:: utils.db.DB
    :members:
    :undoc-members:
    :show-inheritance: