# Load and Save data in yaml file in capistrano

**URL:** <https://www.ruby-forum.com/t/load-and-save-data-in-yaml-file-in-capistrano/160446>\
**Category:** Rails\
**Created:** [February 16, 2009, 2:02pm UTC](https://www.ruby-forum.com/t/load-and-save-data-in-yaml-file-in-capistrano/160446 "2009-02-16T14:02:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![artchrst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@artchrst](https://www.ruby-forum.com/u/artchrst)\
**Post date:** [February 16, 2009, 2:02pm UTC](https://www.ruby-forum.com/t/load-and-save-data-in-yaml-file-in-capistrano/160446/1 "2009-02-16T14:02:52Z")

</div>

Hi All,

I tried to request user to input username and password for the database  
when deploy, therefore, in my capistrano task, I

```
task :create_database_user do
  @username = Capistrano::CLI.password_prompt('mysql_username: ')
  @password = Capistrano::CLI.password_prompt('mysql_password: ')

  #@config = YAML::load( File.open(

```

“#{release\_path}/config/config.yml”))[‘production’]  
@config[“username”] = @username  
@config[“password”] = @password

```
end

```

However, File not found error occurs.

Actually, I want to save the input in the .yml file so that I can access  
them before restart in the database.yml.

Or, Can I save the cap input into the database.yml directly before  
restart?

How can I do that?

Thanks much!  
Arthur

---

<div class="post-metadata">

**Author:** ![artchrst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@artchrst](https://www.ruby-forum.com/u/artchrst)\
**Post date:** [February 17, 2009, 1:15am UTC](https://www.ruby-forum.com/t/load-and-save-data-in-yaml-file-in-capistrano/160446/2 "2009-02-17T01:15:31Z")

</div>

Did you mean  
“#{release\_path}/config/database.yml”

instead of  
“#{release\_path}/config/config.yml”

On Feb 16, 8:02 am, Arthur C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![artchrst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@artchrst](https://www.ruby-forum.com/u/artchrst)\
**Post date:** [February 17, 2009, 2:21am UTC](https://www.ruby-forum.com/t/load-and-save-data-in-yaml-file-in-capistrano/160446/3 "2009-02-17T02:21:37Z")

</div>

Jeff Emminger wrote:

> Did you mean  
> “#{release\_path}/config/database.yml”
> 
> instead of  
> “#{release\_path}/config/config.yml”
> 
> On Feb 16, 8:02ï¿½am, Arthur C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Yes and no. I wanna update the database.yml. But the main reason I do  
this task is to protect the password, so I should not write anything  
there. Instead, I wanna create an object to hold the MYSQL login and put  
it in the database.yml:

development:  
adapter: mysql  
database: arthur\_dev  
username: \<%= username %\>  
password: \<%= password %\>

The problem is in Capistrano that I don’t know how to retrieve the  
password from Capistrano  
“Capistrano::CLI.password\_prompt('mysql\_username: ')”.

Thanks much!  
Arthur
