Objectbox-java: Object Browser App

Created on 25 Jan 2017  路  27Comments  路  Source: objectbox/objectbox-java

Allow to open ObjectBox databases with a generic browser.

Main question: should this be something you can integrate into an app? Or do you prefer an desktop app? Or a web app?

Pro app:

  • no need to pull database files to the desktop

Pro desktop:

  • More screen estate
  • Also works for non-Android databases, e.g. desktop apps and unit tests

Pro web app (e.g. write server in Kotlin with embedded netty):

  • More screen estate
  • Can be accessed locally on the device or on the desktop
  • Also works for non-Android databases, e.g. desktop apps and unit tests
  • Remotely accessible, e.g. you could use ObjectBox on a server and connect to it

Pro Stetho

  • Existing infrastructure

What would you prefer and why?

feature

Most helpful comment

@greenrobot I hacked something: https://github.com/mreichelt/ObjectBox-viewer

  1. Run the sample app
  2. Run adb forward tcp:8912 tcp:8912 to forward the internal port to the host machine
  3. Go to http://localhost:8912 and observe:
    objectbox browser

Some notes:

  • Technically possible, yay!
  • Currently devs have to pass in the Entity classes, which we might be able to find via reflection -> yay
  • We might also get the Entity data via reflection -> yay
  • Currently devs have to start the HTTP server manually - this might be required because the viewer needs access to the BoxStore instance -> nay
  • For now I don't know if we can automate the port forwarding - this could be an issue for developers when the emulator/device is restarted/reconnected and they wonder why http://localhost:8912 does not work anymore

All 27 comments

I think, Stetho plugin would be enough for the first time. Realm users on Linux and Windows use such kind of database access because native realm browser app is only available for MacOS.

Very agree with you!

The realm browser app is fantastic for iOS development, since the simulator's filesystem lives on your Mac's filesystem. It's not really so useful for Android development though, due to having to pull DBs off the phone before being able to do anything.

If your primary usecase is Android, a Stetho plugin (or something that works like Stetho) is a great idea. If you want something that'll work cross-platform though, is there an option other than a desktop app?

Actually, I think doing it as an embedded web server might be the best option in the long run. Maybe with web components (ping @mreichelt).

Yay, web components! :D
I also believe that a server containing a small web app would be the coolest way to do it.

And it shouldn't be too hard to accomplish. Especially making it an optional debug only dependency could save a lot of time.

@greenrobot I hacked something: https://github.com/mreichelt/ObjectBox-viewer

  1. Run the sample app
  2. Run adb forward tcp:8912 tcp:8912 to forward the internal port to the host machine
  3. Go to http://localhost:8912 and observe:
    objectbox browser

Some notes:

  • Technically possible, yay!
  • Currently devs have to pass in the Entity classes, which we might be able to find via reflection -> yay
  • We might also get the Entity data via reflection -> yay
  • Currently devs have to start the HTTP server manually - this might be required because the viewer needs access to the BoxStore instance -> nay
  • For now I don't know if we can automate the port forwarding - this could be an issue for developers when the emulator/device is restarted/reconnected and they wonder why http://localhost:8912 does not work anymore

@mreichelt Cool! Thanks for investigating.

Some comments:

  • NanoHTTPD sounds familiar, think I used it before. Nice that it also supports SSL and WebSockets.
  • In the same network, it should be possible to connect directly with the devices IP address, right? --> Log/show the IP.
  • There will be a generic interface to ObjectBox to enable discovering available object types. Also a generic way to access object's data (without knowing Java classes, think of an object more like Map with property name keys).

Btw, do you know a powerful datagrid web component? Saw the one from Vaadin on top of Polymer, but not sure about it..

I'd go with a stetho plugin for the simple reason that it has virtually no overhead to setup.

@ArthurSav where is the stetho plugin for objectbox?

@luozheng1985 there is no steho plugin. We'll probably go a different route here.

Update: we started working on this and want to release soon after 1.0.
The plan is to offer a web based data browser (using an embedded web server in a debug version of the library). Maybe Polymere based? Thoughts welcome.

Please don't have the same strong connection Stetho uses. It's such a PITA to reattach each time the app is restarted!

@greenrobot Hi, i just made simple objectbox browser based on https://github.com/amitshekhariitbhu/Android-Debug-Database.

Add, edit, delete operations are not supported (for now), only display.
You can download (if you want) library with sample project (made in As 2.3.3) from https://github.com/kosiarska/ObjectBoxDebugBrowser

Please tell me what you think. Btw. your libraries saved me many times :), thank you for your amazing work.

How to see the database and table in android mobiles

How to write the database in sd card for seeing the data in android

https://github.com/renyuzhuo/rviewer

Getting started

In your build.gradle:

 dependencies {
   debugCompile 'cn.renyuzhuo.rviewer:rviewer:1.0.2'
   releaseCompile 'cn.renyuzhuo.rviewer:rviewer-no-op:1.0.2'
 }

In your Application class:

public class App extends Application {

    private BoxStore boxStore;
    private static App app;

    @Override
    public void onCreate() {
        super.onCreate();
        boxStore = MyObjectBox.builder().androidContext(this).build();
        app = this;

        ArrayList<Class> classes = new ArrayList<>();
        classes.add(Note.class); // Your Entitys
        ObjectViewBoxManager.getInstance().init(boxStore, classes);
    }
}

Notice: You Should all Add toString() like:

    @Override
    public String toString() {
        return "Note{" +
                "id=" + id +
                ", text='" + text + '\'' +
                ", date=" + date +
                '}';
    }

All the things is done.

Is there any desktop software can access data.mdb?@greenrobot

I'm sorry , I use Stetho, but there is no any db file.
image
And I'm sure that I have a data.mdb file. I use RE can find the file
image
Why there is show nothing in the Stetho?
@Bringoff

@iBotasky

I don't believe Stetho is supported.
You have to use the objectbox browser

@ArthurSav OK, Let me try for it, thanks!

Hello all,
I created SQLScout, a plugin for Android Studio, that provides support for Sqlite:

  • Automatic generation of Room Entity, DAO and Database classes from existing database schemas.
  • Ability to connect to SQLite databases in Android devices (without downloading database files) and the file system
  • Database schema explorer (view tables, views, columns, primary keys, foreign keys, etc.)
  • SQL editor (syntax highlighting, code completion, reference navigation, refactoring, etc.)
  • Data console to view query results, edit table data, and export contents to different formats
  • Database diagrams
    (More details and demos here)

We are thinking about creating another plugin that provides similar features, but for ObjectBox (including automated migration from SQLite to ObjectBox.)

Our question is, would ObjectBox users consider using this plugin?

Many thanks in advance.

@yvonneprice

Current implementation of the objectbox browser is nice but it lucks a lot of stuff. Also it forces you to go out of your flow(IDE) in order to debug.

So i'd probably use it given that it's part of intellij

@ArthurSav
Thank you for your feedback. I completely agree, having all the tooling, including database management integrated in one place (inside IDE) minimizes context switching and flow interruptions, increasing developers' productivity.

The idea of objectbox browser is nice but only work for Android project. I think we need a way to access the data file directly on Desktop.

@nguyenxndaidev Please thumbs up or give #519 some love. -ut

Was this page helpful?
0 / 5 - 0 ratings