// Insert data into the "accounts" table
const stmt = db.prepare('INSERT INTO accounts (private_key, address, decimalNumber, has_transactions) VALUES (?, ?, ?, ?)');
stmt.run('private_key_value', 'address_value', 'decimalNumber_value', 1, function(err) {
if (err) {
console.error('Error inserting data:', err.message);
} else {
console.log(`A row has been inserted with rowid ${this.lastID}`);
}
});
stmt.finalize();
db.prepare()
: Prepares an SQL statement for execution.stmt.run()
: Executes the prepared statement with the provided values.- The
?
placeholders are replaced by the corresponding values in order. - In this example:
'private_key_value'
: Replace with the actual private key.'address_value'
: Replace with the actual wallet address.'decimalNumber_value'
: Replace with the actual decimal number or relevant value.1
: Represents true
for the has_transactions
boolean field (use 0
for false
).this.lastID
: Provides the row ID of the last inserted row.stmt.finalize()
: Finalizes the statement, releasing resources.