from dotenv import load_dotenv
import os

load_dotenv()

pg_name = os.getenv("TIMESCALEDB_DB_NAME")
pg_host = os.getenv("TIMESCALEDB_DB_HOST")
pg_port = os.getenv("TIMESCALEDB_DB_PORT")
pg_user = os.getenv("TIMESCALEDB_DB_USER")
pg_password = os.getenv("TIMESCALEDB_DB_PASSWORD")


def get_pgconn_string(
    db_name=pg_name,
    db_host=pg_host,
    db_port=pg_port,
    db_user=pg_user,
    db_password=pg_password,
):
    """返回 PostgreSQL 连接字符串"""
    return f"dbname={db_name} host={db_host} port={db_port} user={db_user} password={db_password}"


def get_pg_config():
    """返回 PostgreSQL 配置变量的字典"""
    return {
        "name": pg_name,
        "host": pg_host,
        "port": pg_port,
        "user": pg_user,
    }


def get_pg_password():
    """返回密码（谨慎使用）"""
    return pg_password
