Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!