Nozbe / WatermelonDB

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

Is there a tool like realm studio? for example: watermelonDB studio #105

Open anhtbok92 opened 5 years ago

anhtbok92 commented 5 years ago

Hi, currently I'm working with React Native, using watermelonDB. Sometimes, I want to check my data in the database, but there is no way. I am wanting to have a tool like realm studio or mysql workbench. Is there any way to do the same thing? Thank you.

bsr203 commented 5 years ago

try this.

It was working well earlier for me. May be due to my setup, it is not now in another project. Please let me know how it goes with you.

radex commented 5 years ago

If you can find the database file on disk, you can open it using some app that can read SQLite databases. (For example sqlite3 CLI tool). On iOS, you can set the debugger in Xcode to stop at Database.swift init method and see what the path is. On Android, you'd probably want to use adb shell.

radex commented 5 years ago

It would be great, if someone wanted to contribute an update to the documentation explaining this!

jon-dearaujo commented 5 years ago

I've found this StackOverflow answer really useful for this case.

It describes how to use adb (Android) to pull the database's .db file from the device to the computer. The only differences I've noticed were:

After that we can use whichever tool we want to access the.db file. In my case, I am using dbeaver

radex commented 5 years ago

@jon-dearaujo If you had a few moments to contribute debugging tips to docs, that'd be great!

esbenp commented 5 years ago

Tip: If your on OSX you can get the data path of the currently open simulator by running xcrun simctl get_app_container booted com.example.app - of course replace com.example.app

So you can do something $(xcrun simctl get_app_container booted com.example.app)/Documents/[databasename].db to get the full path. If somebody figures out how to pipe this into dbeaver, please let me know :-)

radex commented 5 years ago

@esbenp please send a quick PR to the documentation with this tip (and the ones above) — that will be much easier for others to find :)

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

fabianmedina09 commented 4 years ago

2020 Update

"@nozbe/watermelondb": "^0.19.0", "@nozbe/with-observables": "^1.0.5", "react": "16.13.1", "react-native": "^0.63.0",

In my case the file was not in the databases folder,

you can find it here: adb exec-out run-as com.package ls /data/data/com.package/watermelon.db

And to get the file to your adb path with this: adb exec-out run-as com.package cat /data/data/com.package/watermelon.db > /data/watermelon.db

You should also get these two files: watermelon.db-shm watermelon.db-wal

To be able to see the data in a tool DBBrowser

I had to use adb exec-out instead of adb shell due to a permission error when wanting to manipulate files

alwex commented 3 years ago

2020 Update for iOS simulator

Here is what I had success with. First install sqlite browser:

brew cask install db-browser-for-sqlite

then just create a bash script with this content (update the bundle id)

#!/bin/bash

BUNDLE_ID=org.reactjs.native.example.MyAwesomeApp
cd $(xcrun simctl get_app_container booted $BUNDLE_ID)
cd ../../../../Data
find . -name 'watermelon.db' -exec open {} \;

this script is not the best, but it works for me.

diegolmello commented 3 years ago

Just to mention how we do :) We can have multiple database and need them to work on app and app extension, so we set the database name and log that path. The rest is just opening .db files in DBBrowser.

On Android, it's a matter of inspecting Device File Explorer on Android Studio and saving .db files on some local folder that DBBrowser can read.

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

KrisLau commented 3 years ago

2020 Update for iOS simulator

Here is what I had success with. First install sqlite browser:

brew cask install db-browser-for-sqlite

then just create a bash script with this content (update the bundle id)

#!/bin/bash

BUNDLE_ID=org.reactjs.native.example.MyAwesomeApp
cd $(xcrun simctl get_app_container booted $BUNDLE_ID)
cd ../../../../Data
find . -name 'watermelon.db' -exec open {} \;

this script is not the best, but it works for me.

Another method for IntelliJ users is to connect to the database from the database window then adding the Data Source from Path and using the path from xcrun simctl get_app_container booted $BUNDLE_ID and then cd ../../../../Data/Application/<folder name from the previous command>/Documents. Is there a plan to eventually create a tool for WatermelonDB?

KrisLau commented 2 years ago

@fabianmedina09 image image

I'm not sure what to do with this? I'm trying to view the database using DB Browser for SQLite but I can't seem to find the Android database on my computer. It was pretty easy for my iOS emulator