const sqlite3 = require('sqlite3').verbose();
function initialise() {
const db = new sqlite3.Database('./restaurants.sqlite');
try {
db.serialize(function () {
db.run("CREATE TABLE RESTAURANTS (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, imagelink TEXT)");
let stmt;
try {
stmt = db.prepare(`INSERT INTO RESTAURANTS (name, imagelink) VALUES (?, ?)`);
stmt.run('Bayroot', 'https://www.telegraph.co.uk/content/dam/Travel/Destinations/Europe/England/Brighton/brighton-restaurants-hotel-du-vin-bistro.jpg');
} finally {
stmt.finalize();
}
db.each("SELECT * FROM Restaurants",
function (err, rows) {
console.log(rows);
}
);
});
} finally {
db.close();
}
}
Jdbi jdbi = Jdbi.create("jdbc:sqlite:restaurants.sqlite");
List<Map<String, Object>> restaurants = jdbi.withHandle(handle -> {
handle.execute("CREATE TABLE RESTAURANTS (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, imagelink TEXT)");
handle.execute("INSERT INTO RESTAURANTS (name, imagelink) VALUES (?, ?)", "Bayroot", "https://www.telegraph.co.uk/content/dam/Travel/Destinations/Europe/England/Brighton/brighton-restaurants-hotel-du-vin-bistro.jpg");
return handle.createQuery("SELECT * FROM RESTAURANTS")
.mapToMap()
.list();
});
System.out.println(restaurants);
}