WatermelonDB icon indicating copy to clipboard operation
WatermelonDB copied to clipboard

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

Open anhtbok92 opened this issue 8 years ago • 15 comments

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.

anhtbok92 avatar Oct 22 '18 04:10 anhtbok92

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.

bsr203 avatar Oct 22 '18 10:10 bsr203

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 avatar Oct 22 '18 11:10 radex

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

radex avatar Oct 25 '18 11:10 radex

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/<com.yourpackge.name>/databases/ to access the .db file, watermelon.db file is placed at /data/data/<com.yourpackge.name>/watermelon.db;

  • 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 avatar Nov 18 '18 19:11 jon-dearaujo

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

radex avatar Nov 19 '18 08:11 radex

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 avatar Jan 13 '19 09:01 esbenp

@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 :)

radex avatar Jan 14 '19 08:01 radex

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] avatar Apr 14 '19 08:04 stale[bot]

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] avatar Oct 12 '19 15:10 stale[bot]

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

fabianmedina09 avatar Sep 14 '20 14:09 fabianmedina09

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.

alwex avatar Oct 04 '20 00:10 alwex

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.

diegolmello avatar Oct 05 '20 13:10 diegolmello

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.

stale[bot] avatar Jul 21 '21 03:07 stale[bot]

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 avatar Aug 31 '21 14:08 KrisLau

@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

KrisLau avatar Oct 18 '21 02:10 KrisLau