Connection.py 870 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. """PostgreSQL 连接池(向后兼容 re-export 层)。
  3. Phase 1 重构后真实实现在 BiddingKG.dl.infra.db。
  4. 本文件与 interface/Connection.py 原本完全一致,已合并为统一实现。
  5. 原硬编码:
  6. host="192.168.2.101", user="postgres", password="postgres"
  7. 已移除,改走 config/db.yaml + 环境变量。
  8. """
  9. from __future__ import absolute_import
  10. from BiddingKG.dl.infra.db import get_connection as _get_connection, get_pool as _get_pool
  11. __all__ = ["getConnection", "pool"]
  12. def getConnection():
  13. """原 common/Connection.getConnection(),默认 BiddingKG 库。"""
  14. return _get_connection("BiddingKG")
  15. def get_connection(dbname="BiddingKG"):
  16. """显式按库名取连接。"""
  17. return _get_connection(dbname)
  18. # 向后兼容:保留模块级 pool 变量名(原为 None 占位)
  19. pool = None