Web Scrapers Generator BrowserExt

dbinsert

Insert the record with the given attributes into the database.

dbinsert(connection, table, attrs)
    

Parameters:

connection Connection ID established by dbconnect.
table Table name.
attrs Dictionary of attributes that will be inserted into a database table. The key of the dictionary corresponds to the name of a column in a table.

Returned value: the value of the primary key of the inserted record.

This function can not be executed in the "Editor".

Example 1. Lets suppose that there is products table in the test database, containing id, t, d and p columns. At the first place we form the table from the returned data, then we will search for every row in the database. If we don't find a record with the relevant data, then insert a new record to the database.