config.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import pymysql
  2. class db_config:
  3. def __init__(self):
  4. self.db_ip = "192.168.1.200" # 数据库IP地址
  5. self.db_port = 3306 # 端口号
  6. self.db_name = "xm_project" # 数据库名
  7. self.db_user = "zx" # 用户名
  8. self.db_password = "123456" # 用户密码
  9. self.db_charset = "utf8" # 数据库连接编码
  10. self.db_mincached = 10 # mincached : 启动时开启的闲置连接数量(缺省值 0 开始时不创建连接)
  11. self.db_maxcached = 10 # maxcached : 连接池中允许的闲置的最多连接数量(缺省值 0 代表不闲置连接池大小)
  12. self.db_maxshared = 20 # maxshared : 共享连接数允许的最大数量(缺省值 0 代表所有连接都是专用的)如果达到了最大数量,被请求为共享的连接将会被共享使用
  13. self.db_maxconnecyions = 100 # maxconnecyions : 创建连接池的最大数量(缺省值 0 代表不限制)
  14. self.db_blocking = True # blocking : 设置在连接池达到最大数量时的行为(缺省值 0 或 False 代表返回一个错误<toMany......> 其他代表阻塞直到连接数减少,连接被分配)
  15. self.db_maxusage = 0 # maxusage : 单个连接的最大允许复用次数(缺省值 0 或 False 代表不限制的复用).当达到最大数时,连接会自动重新连接(关闭和重新打开)
  16. self.db_setsession = None # setsession : 一个可选的SQL命令列表用于准备每个会话,如["set datestyle to german", ...]
  17. self.db_creator = pymysql # creator : 使用连接数据库的模块
  18. DB_CONFIG = db_config()
  19. class mq_config:
  20. def __init__(self):
  21. self.mq_ip = "192.168.1.200" # rabbitmq服务器ip地址
  22. self.mq_port = 5672 # 端口
  23. self.mq_user = "zx" # 用户名
  24. self.mq_password = "123456" # 用户密码
  25. self.mq_command_exchange_name = "command_ex" # 指令交换机名
  26. self.mq_statu_exchange_name = "statu_ex" # 状态交换机名
  27. self.mq_statu_exchange_keys = [[self.mq_statu_exchange_name, "dispatch_11_statu_port"],
  28. [self.mq_statu_exchange_name, "dispatch_12_statu_port"],
  29. [self.mq_statu_exchange_name, "dispatch_13_statu_port"],
  30. [self.mq_statu_exchange_name, "dispatch_14_statu_port"],
  31. [self.mq_statu_exchange_name, "dispatch_21_statu_port"],
  32. [self.mq_statu_exchange_name, "dispatch_22_statu_port"],
  33. [self.mq_statu_exchange_name, "dispatch_23_statu_port"],
  34. [self.mq_statu_exchange_name, "dispatch_24_statu_port"],
  35. [self.mq_statu_exchange_name, "dispatch_25_statu_port"],
  36. [self.mq_statu_exchange_name, "dispatch_31_statu_port"],
  37. [self.mq_statu_exchange_name, "dispatch_32_statu_port"]] # 状态交换机需要订阅的端口列表
  38. MQ_CONFIG = mq_config()