How can I replace a value already present in the database? Is there a way for db_insert() to overwrite existing entries?
As @kiamlaluno mentioned db_insert() inserts a new row in the table. You can use db_update(), to update the row if it already exists. You can use db_merge(), to combine both of them.
See the example (taken from the documentation):

db_merge('example')
  -&gt;key(array('name' =&gt; $name))
  -&gt;fields(array(
      'field1' =&gt; $value1,
      'field2' =&gt; $value2,
    ))
  -&gt;execute();



  In the above example, we instruct the query to operate on the "example" table. We then specify one key field, 'name', with a value of $name. We then specify an array of values to set.
  
  If a row already exists in which the field "name" has the value $name, then fields field1 and field2 will be set to the corresponding values in that existing row. If such a row does not exist, one will be created in which name has the value $name, field1 has the value $value1, and field2 has the value $value2. Thus at the end of the query, the end result is the same regardless of whether or not the row already existed.