Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to dump to sqlite file? #64

Open
ununian opened this issue Oct 11, 2022 · 6 comments
Open

How to dump to sqlite file? #64

ununian opened this issue Oct 11, 2022 · 6 comments

Comments

@ununian
Copy link

ununian commented Oct 11, 2022

and import sqlite file

@quolpr
Copy link
Contributor

quolpr commented Oct 11, 2022

For which platform? Web, desktop, mobile?

@astahmer
Copy link

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

@ununian
Copy link
Author

ununian commented Oct 12, 2022

web platform。Thanks for your reply

@ununian ununian closed this as completed Oct 12, 2022
@quolpr
Copy link
Contributor

quolpr commented Oct 12, 2022

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

@quolpr quolpr reopened this Oct 12, 2022
@ununian
Copy link
Author

ununian commented Oct 13, 2022

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

@quolpr
Copy link
Contributor

quolpr commented Oct 13, 2022

@ununian I will add support once I finish this PR #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 quolpr mentioned this issue Oct 16, 2022
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants