常见数据库连接设置

mysql:

    mysql_config = {
        "host": "",
        "port": 3306,
        "user": "",
        "password": "",
        "db": "",
        "cursorclass": DictCursor,  # 字典游标
        "autocommit": True,
        "charset": "utf8"
    }

redis:

    CONFIG_REDIS_YQ_NEW = {
        "host": "",
        "port": ,
        "auth": "",
        "index": ,
        "encoding": "utf-8",
        "decode_responses": True,  # 返回的时候解码
        "target_max_memory": 3896,
        "max_connections": 1  # 最大连接数
    }

mongodb:

MONGO_CFG_USER = {
    "write_host": "",  # (master)
    "read_host": "",  # (slave)
    "username": "",
    "password": "",
    "db": "",
}

elasticsearch:

from elasticsearch import Elasticsearch
es_client = Elasticsearch(hosts="ip:port")

你可能感兴趣的:(常见数据库连接设置)