Git Product home page Git Product logo

Comments (8)

asika32764 avatar asika32764 commented on June 12, 2024

I found that I can read DB raw data by:

const url = await db.getUrl();
  
  const file = await Filesystem.readFile({
    path: url.url!,
    encoding: Encoding.ASCII
  });

  const time = dateFormat('yyyy-MM-dd-HH-mm-ss');

  const r = await Filesystem.writeFile({
    path: `db/backup-${time}.db`,
    data: file.data,
    directory: Directory.Documents,
    recursive: true,
    encoding: Encoding.ASCII
  });

But after write to Documents and trying to read it by DB explorer, this file will corrupted and shows

Error encountered when performing Introspect schema main: [SQLITE_CORRUPT] The database disk image is malformed

Trying to compare it with the original db files in databases/, they are totally same file size, and same line numbers.

screenshot 2023-12-03 δΈ‹εˆ7 18 05

Any idea about deal this issue?

from sqlite.

asika32764 avatar asika32764 commented on June 12, 2024

I still not understand why read and write the db file will cause corrupted.

But finally I can read the db file if I use copy method. This is my solution:

const url = await db.getUrl();

  const time = dateFormat('yyyy-MM-dd-HH-mm-ss');

  const r = await Filesystem.copy({
    from: url.url!,
    to: `db/backup-${time}.db`,
    toDirectory: Directory.Documents
  });

from sqlite.

jepiqueau avatar jepiqueau commented on June 12, 2024

@asika32764 Are you on Android 13 API 33

from sqlite.

asika32764 avatar asika32764 commented on June 12, 2024

on simulator with Android 11 API 30

screenshot 2023-12-07 δΈ‹εˆ9 04 11

from sqlite.

jepiqueau avatar jepiqueau commented on June 12, 2024

@asika32764 thanks for this for me using copy is the best as it is a deep copy. May be it is due to the Encoding.ASCII may be it would have work with Encoding.UTF8. In my tutorials, can i use your suggestion if ones wants also to backup their database

from sqlite.

jepiqueau avatar jepiqueau commented on June 12, 2024

@asika32764 which is the application DB explorer that you are using in iOS and Android to read the database

from sqlite.

jepiqueau avatar jepiqueau commented on June 12, 2024

@asika32764 No news from you so i close it

from sqlite.

asika32764 avatar asika32764 commented on June 12, 2024

I'm using webstorm / phpstorm database reader.

I tried to compare 2 files but it seems they are same, I think maybe due to some difference in the file metadata.

from sqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.