Soy nuevo en este campo y acabo de comenzar mi primer proyecto y estoy usando sqlite3 como base de datos.
// can insert this array as a row var myArray = ["bob","16","student","Bosh University","football",]este es mi código... ya he creado la tabla
let infoTable = new sqlite3.Database('./all/infoTable.db', (err) => { if (err) console.error(err.message) }); infoTable.run(`CREATE TABLE IF NOT EXISTS infoTable (name TEXT, age INTEGER, status TEXT, workPlace TEXT , intrest TEXT)`)¿Puedo insertar esta matriz como una fila en la base de datos?
Podrías intentar algo así:
var myArray = ["bob","16","student","Bosh University","football"]; infoTable.run('\ INSERT INTO \ infoTable(name TEXT, age INTEGER, status TEXT, workPlace TEXT , intrest TEXT) \ VALUES \ (?, ?, ?, ?, ?)', ...myArray);Tienen una buena referencia de API .