kikko icon indicating copy to clipboard operation
kikko copied to clipboard

How to dump to sqlite file?

Open ununian opened this issue 2 years ago • 6 comments

and import sqlite file

ununian avatar Oct 11 '22 15:10 ununian

For which platform? Web, desktop, mobile?

quolpr avatar Oct 11 '22 17:10 quolpr

I was also wondering how to do that for the web platform ! I figured it might already be possible using something like https://sql.js.org/#/?id=write-a-database-to-the-disk ? but idk if we can use that export function with @kikko-land/sql.js

astahmer avatar Oct 11 '22 21:10 astahmer

web platform。Thanks for your reply

ununian avatar Oct 12 '22 02:10 ununian

@astahmer yeah, I think I will expose API for dumping and loading SQLite db

quolpr avatar Oct 12 '22 19:10 quolpr

@quolpr
Can you expose api for reading and writing files? I want to write files in indexeddb before initDbClient

ununian avatar Oct 13 '22 12:10 ununian

@ununian I will add support once I finish this PR https://github.com/kikko-land/kikko/pull/61 , that adds massive changes to the code.

You will be able to call before initDbClient, the API will look something like this:

const backend = absurdWebBackend({
  wasmUrl: sqlWasmUrl,
});

const config: IInitDbClientConfig = {
  dbName: "db-name",
  dbBackend: backend,
  plugins: [
    migrationsPlugin({ migrations: [createNotesTableMigration] }),
    reactiveQueriesPlugin(),
  ],
};

const data = backend.export() // exporting DB Uint8Array
backend.load(data) // loading DB

quolpr avatar Oct 13 '22 15:10 quolpr