常见数据库连接设置
2018-09-05 本文已影响0人
陆_志东
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")