私は小さなユーティリティを書いて、あるsqliteデータベースファイルから別のものにデータをコピーしています。どちらのファイルも同じテーブル構造になっています。node-sqliteを使用してあるDBから別のDBにデータをコピーする - '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オブジェクトです。私は、ストリング化されたデータをエスケープすることを伴わない簡単な方法があることは確かです。