Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.56k stars 595 forks source link

WatermelonDB viewer? #710

Closed finom closed 3 years ago

finom commented 4 years ago

Hey guys! Is there a tool which allows to look at tables visually? I'm developing a normal multi table DB and I need to check how do fields populated, removed etc. CLI output is also OK.

djorkaeffalexandre commented 4 years ago

Hey @finom, you can use DB Browser for SQLite. https://sqlitebrowser.org/

finom commented 4 years ago

@djorkaeffalexandre thank you but how can I open a DB which is in an emulator?

djorkaeffalexandre commented 4 years ago

I think it's logged to someplace that I never saw. @radex where we can see this log? https://github.com/Nozbe/WatermelonDB/blob/876fe190f2dc57820780b11522c43d15b170f384/native/ios/WatermelonDB/Database.swift#L30

radex commented 4 years ago

in the iOS system log -- e.g. via xcode

davidsonsns commented 4 years ago

This comment can also help you all, at least for me it was https://github.com/Nozbe/WatermelonDB/issues/105#issuecomment-453815987

@radex I'm thinking about creating a reference for that on the documentation. Sharing how to find the complete path to watermelon.db file. Once with that, we can easily open any SQLite GUI to see data. Sounds good?

radex commented 4 years ago

@davidsonsns Yes, please do! That would be very helpful to a lot of people to have it right in the docs. Find (or make) the right file in docs-master/ (the docs/ folder is compiled when releasing a new version of 🍉, don't worry about that)

StefanBlamberg commented 4 years ago

The new database inspector which comes with the Android Studio Beta version is also a very convenient and powerful tool to inspect the Android emulator database Works perfectly with Watermelon

https://medium.com/androiddevelopers/database-inspector-9e91aa265316

mattfrances commented 3 years ago

For viewing the watermelon db using an iOS simulator on Mac, check out this stackoverflow link which has the following steps:

  1. cd /Users//Library/Developer/CoreSimulator/Devices
  2. find . -name "{your database name}.db"
  3. sqlite 3 /Users//Library/Developer/CoreSimulator/Devices/{paste the path outputted from Step 2 here}

Once complete, you'll be able to access your tables using the CLI! (btw the brackets {} in step 2 and 3 should not be included when performing your commands, they just indicate placeholders)

kkkasio commented 3 years ago

Hello friends, I develop with React Native, I almost always need to keep looking at the database during development. to get my file straight from my emulator I use the following command:

adb shell "run-as com.package.name cat /data/data/com.package.name/watermelon.db" > ./your_pc_path_folder/watermelon.db

and later I use another program (DBeaver, Beekeeper) to view the file. I lost some time, but I soon found the above solution. I wouldn't want to get involved with Android Studio's "App Inspector"

KrisLau commented 3 years ago

@kkkasio What would be the pc path folder? Is that the path to my project?

kkkasio commented 2 years ago

@kkkasio What would be the pc path folder? Is that the path to my project?

Sorry for the delay, your pc folder must be the directory you want to export the database.

KrisLau commented 2 years ago

@kkkasio When I try to open the file, it says: image

Danu-rxone commented 4 months ago

My workaround in RN 0.73.8:

In the android directory: cd ./android

and run the following command: run adb shell "run-as com.valnas cat /data/data/com.valnas/ValidationDB.db" > ../database.db

The database name should come from your configuration:

const adapter = new SQLiteAdapter({
  dbName: 'ValidationDB',
  schema,
  migrations,
  jsi: true /* Platform.OS === 'ios' */,
  onSetUpError: error => {
    console.warn(error, 'on SetUp Error');
  },
});

Then you will get database.db in the root of the project.

You can open this file in any database viewer, such as DB Browser for SQLite.

iAmHammad261 commented 1 week ago

I followed the steps mentioned by the @Danu-rxone and I have obtained the .db file.

But when I open the .db file using the browser for sq lite it shows zero tables. image

How can I fix the above issue?

gabrielforcellini commented 1 week ago

This worked for me on windows:

  1. Go to android directory cd ./android
  2. Find the database
    adb shell
    run-as com.package.name
    cd /data/data/com.package.name/
    ls
  3. Exit the adb shell
  4. Run
    adb pull /data/data/com.package.name/your-database-name.db.db ./your_pc_path_folder/watermelon.db
  5. Open in DB Browser for SQLite image