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.
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.
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.
It would be great, if someone wanted to contribute an update to the documentation explaining this!
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:
instead of using _/data/data/
I had to use _cp_ instead of _cat_ to copy the file to /sdcard/. Take a look at the post
After that we can use whichever tool we want to access the.db file. In my case, I am using dbeaver
@jon-dearaujo If you had a few moments to contribute debugging tips to docs, that'd be great!
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 :-)
@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 :)
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.
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.
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
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.
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.
Most helpful comment
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.appSo you can do something
$(xcrun simctl get_app_container booted com.example.app)/Documents/[databasename].dbto get the full path. If somebody figures out how to pipe this into dbeaver, please let me know :-)