def get_db_config()

in polardb-postgresql-mcp-server/server.py [0:0]


def get_db_config():
    """Get database configuration from environment variables."""
    config = {
        "host": os.getenv("POLARDB_POSTGRESQL_HOST", "localhost"),
        "port": int(os.getenv("POLARDB_POSTGRESQL_PORT", "5432")),
        "user": os.getenv("POLARDB_POSTGRESQL_USER"),
        "password": os.getenv("POLARDB_POSTGRESQL_PASSWORD"),
        "dbname": os.getenv("POLARDB_POSTGRESQL_DBNAME"),
        "application_name": f"polardb-postgresql-mcp-server-{VERSION}"
    }
    
    if not all([config["user"], config["password"], config["dbname"]]):
        logger.error("Missing required database configuration. Please check environment variables:")
        logger.error("POLARDB_POSTGRESQL_USER, POLARDB_POSTGRESQL_PASSWORD, and POLARDB_POSTGRESQL_DBNAME are required")
        raise ValueError("Missing required database configuration")
    
    return config