an experiment in putting together a wiki and an object-oriented mud.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
1.1 KiB

const sqlite = require("better-sqlite3");
const sqlite3_db = new sqlite('./the_big_db.db', { verbose: console.log });
const libsql = require("@libsql/client");
const config = {url: "http://127.0.0.1:8000"};
const libsql_db = libsql.createClient(config);
async function copyPages() {
console.log("copying everythting from hte old db");
const pages = (await libsql_db.execute(`select id, title, description, html from pages`)).rows;
const insertPage = sqlite3_db.prepare(`replace into pages (id, title, description, html) values (:id, :title, :description, :html)`);
pages.forEach((page) => {
console.log(`inserting page ${page.id}`)
insertPage.run(page);
});
}
async function copyUsers() {
console.log("copying users now");
const users = (await libsql_db.execute(`select name, password from users`)).rows;
const insertUser = sqlite3_db.prepare(`replace into users (name, password) values (:name, :password)`);
users.forEach((user) => {
console.log(`inserting ${user.name}, ${user.password}`);
insertUser.run(user);
});
}
copyPages();
copyUsers();