Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Updating the sqlite database that is in the project folder

I want to insert a new value and overwrite my SQLite database using this ipc function (electron). Whenever I try to add just one entry to the table, it saves it, but as soon as I close the application the entry is gone. The code I wrote only seems to insert and persist the new entry if I add two entries (only persisting the first one). Any ideas on what might be the issue?

ipcMain.handle("add/Winery", async (event, args) => {
    const db = new sqlite3.Database('./database/Test.db', sqlite3.OPEN_READWRITE, (err) => {
        if (err) return console.error(err.message);

        console.log('Connection successfull in AddWinery');
    });
  
    console.log('location : ' + args[0])
    console.log('email : ' + args[1])
    console.log('phone number : ' + args[2])
    console.log('name : ' + args[3])

    const sql = 'INSERT INTO WINERY (location, email, phone_number, name) VALUES (?,?,?,?)'

    db.run(sql, args, function(err) {
        if (err) {
            console.log(err.message)
        }
            console.log("entry added to table")
        });

    db.close();

    const pathToFile = path.join('./', "database", "Test.db")
    console.log("The path from which the db is taken in addWineries is : " + pathToFile)

    const pathToNewDestination = path.join('C:\\Users\\mario', "Test.db")
    console.log("The path that is overwritten after add is: " + pathToNewDestination)
  
    console.log("writing new db file to C:\Users\Mario")
    fs.copyFileSync(pathToFile, pathToNewDestination)
    console.log("succesfully written file!")
})
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda