I’d like to be able to programatically setup a site to discourage crawling by search engines

You’re looking for blog_public:

update_option( 'blog_public', '0' );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)