Skip to content

Instantly share code, notes, and snippets.

@fmacedoo
Last active July 31, 2020 12:56
Show Gist options
  • Save fmacedoo/5bfc1a3a99bd1e1f608a8630bdd4596c to your computer and use it in GitHub Desktop.
Save fmacedoo/5bfc1a3a99bd1e1f608a8630bdd4596c to your computer and use it in GitHub Desktop.
const { ipcMain } = require('electron');
const sqlite3 = require('sqlite3');
const database = new sqlite3.Database('./public/db.sqlite3', (err) => {
if (err) console.error('Database opening error: ', err);
});
ipcMain.on('asynchronous-message', (event, arg) => {
const sql = arg;
database.all(sql, (err, rows) => {
event.reply('asynchronous-reply', (err && err.message) || rows);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment