# Writing to a Database from a Script

Once a database table has been defined, Cognex Designer will automatically add a new function that can be called from a script:

- AddRow is a synchronous/block method to insert/add a new row to to the table.

  Calling this function with a value for each column will insert a new row of data into the table. For example:

  $Databases.FastDatabase.Results.AddRow(DateTime.Now(),12345.67, False,"Message");

- QueueAddRow is an asynchronous method to insert/add a new row to the table. The insert will be queued and processed as a bulk insert, processed as soon as possible, but generally every second. If more than a 1000 inserts are already in the queue, then the method will error out.

  $Databases.FastDatabase.Results.QueueAddRow(DateTime.Now(),12345.67, False,"Message");

- Update allows you to update a existing row in a table. The first parameter will be used to match any existing rows in the table. The remaining parameters will replace the existing values for each row where the first column's value matches the first parameter.

  var timestampAsId = new DateTime(2021,01,01);
  $Databases.FastDatabase.Results.Update(timestampAsId, 12345.67, False,"Message");