Connection.py 786 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. """PostgreSQL 连接池(向后兼容 re-export 层)。
  3. Phase 1 重构后真实实现在 BiddingKG.dl.infra.db。
  4. 本文件与 common/Connection.py 原本完全一致,已合并为统一实现,
  5. 此处仅 re-export 以保留 interface.Connection 的导入路径。
  6. 原硬编码:
  7. host="192.168.2.101", user="postgres", password="postgres"
  8. 已移除,改走 config/db.yaml + 环境变量。
  9. """
  10. from __future__ import absolute_import
  11. from BiddingKG.dl.common.Connection import ( # noqa: F401
  12. getConnection,
  13. get_connection,
  14. pool,
  15. )
  16. __all__ = ["getConnection", "get_connection", "pool"]
  17. if __name__ == "__main__":
  18. conn = getConnection()
  19. cursor = conn.cursor()
  20. cursor.execute(" select 1")
  21. print(cursor.fetchall()[0][0])