我正在编写一个小型实用程序,用于将数据从一个sqlite数据库文件复制到另一个。两个文件都有相同的表结构 - 这完全是关于将行从一个数据库移动到另一个数据库。使用node-sqlite将数据从一个数据库复制到另一个数据库 - 格式化'insert'语句
我现在代码:
let tables: Array<string> = [
"OneTable", "AnotherTable", "DataStoredHere", "Video"
]
tables.forEach((table) => {
console.log(`Copying ${table} table`);
sourceDB.each(`select * from ${table}`, (error, row) => {
console.log(row);
destDB.run(`insert into ${table} values (?)`, ...row) // this is the problem
})
})
row
这里是一个js对象,从每个表中的所有键数据。我确信有一个简单的方法可以做到这一点,不涉及转义字符串数据。