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();