Skip to content
This repository was archived by the owner on Aug 3, 2025. It is now read-only.

Delight SQL Viewer is a multiplatform library that integrates database viewing and editing into your application

License

Notifications You must be signed in to change notification settings

bartwell/delight-sql-viewer

Repository files navigation

Delight SQL Viewer

⚠️ Deprecated: Delight SQL Viewer is no longer actively maintained.
For an improved, unified debugging experience — including database inspection, logging, network monitoring, and more — please migrate to Kick: Kotlin Inspection & Control Kit.

Delight SQL Viewer is a Kotlin Multiplatform library for Android, iOS, and Desktop applications. It supports both SQLDelight and Room Multiplatform databases. With version 2.0.0, developers and testers can view, edit, add, and delete records directly within the app—making debugging and QA efficient by enabling real-time inspection and modification of your app’s database state.

Screenshots

tables_list table_content insert_row update_value delete_rows

Features

  • Multiplatform Support: Runs on Android, iOS, and Desktop.
  • Dual Database Support: Seamlessly work with both SQLDelight and Room databases.
  • Database Inspection: View, edit, add, and delete records directly from your app.
  • App Shortcuts: Automatically adds a shortcut entry for quick access (configurable).
  • Easy Integration: Add the necessary dependencies and initialize in your platform-specific code.
  • Configurable for Debug/Release: For debug builds, include full functionality; for release builds, switch to a lightweight stub to reduce app size.

Table of Contents

  1. Installation
  2. Initialization
  3. Launching the Viewer
  4. Shortcuts
  5. Excluding the Library in Release Builds
  6. Contributing
  7. License

Installation

Delight SQL Viewer is published to Maven Central. Add the dependency to your shared (common) module:

// In shared/build.gradle.kts

kotlin {
   sourceSets {
      val commonMain by getting {
         dependencies {
              api("ru.bartwell.delightsqlviewer:runtime:2.0.0")
              api("ru.bartwell.delightsqlviewer:core:2.0.0")
              // Choose the adapter based on your database:
              api("ru.bartwell.delightsqlviewer:sqldelight-adapter:2.0.0")
              // or
              // api("ru.bartwell.delightsqlviewer:room-adapter:2.0.0")
         }
      }
   }
}

For iOS, export the dependencies in your framework {} block to make them available in your iOS framework:

// In shared/build.gradle.kts

framework {
     export("ru.bartwell.delightsqlviewer:runtime:2.0.0")
     export("ru.bartwell.delightsqlviewer:core:2.0.0")
     // Choose the adapter based on your database:
     export("ru.bartwell.delightsqlviewer:sqldelight-adapter:2.0.0")
     // or
     // export("ru.bartwell.delightsqlviewer:room-adapter:2.0.0")
}

Initialization

After adding the appropriate dependencies, initialize Delight SQL Viewer in your platform-specific code by providing the corresponding environment provider along with the database driver.

Android

For SQLDelight:

DelightSqlViewer.init(object : SqlDelightEnvironmentProvider() {
    override fun getDriver() = sqlDelightDriver
    override fun getContext() = this@MainActivity
})

For Room:

DelightSqlViewer.init(object : RoomEnvironmentProvider() {
    override fun getDriver() = roomDatabase
    override fun getContext() = this@MainActivity
})

Note: Both providers require an Android Context along with the respective database instance.

iOS

For SQLDelight:

let provider = SqlDelightEnvironmentProvider(driver: sqlDriver)
DelightSqlViewer.shared.doInit(provider: provider, isShortcutEnabled: true)

For Room:

let provider = RoomEnvironmentProvider(driver: roomDatabase)
DelightSqlViewer.shared.doInit(provider: provider, isShortcutEnabled: true)

Note: The isShortcutEnabled parameter determines whether a shortcut is added to the app icon.

Desktop

For SQLDelight:

DelightSqlViewer.init(object : SqlDelightEnvironmentProvider() {
    override fun getDriver() = sqlDelightDriver
})

For Room:

DelightSqlViewer.init(object : RoomEnvironmentProvider() {
    override fun getDriver() = roomDatabase
})

Note: The isShortcutEnabled parameter determines whether the “SQL Viewer” item is added to the Taskbar/Dock context menu.


Launching the Viewer

Once initialized, you can launch the viewer with a simple call:

Android / Desktop

Button(onClick = { DelightSqlViewer.launch() }) {
    Text(text = "Launch viewer")
}

iOS

Button("Launch viewer") {
    DelightSqlViewer.shared.launch()
}

Using a Custom Theme

Starting with version 2.1.0, you can specify a custom theme when launching the viewer. By default, DelightSqlViewer.launch() uses Theme.Auto, but you may also call:

DelightSqlViewer.launch(theme = Theme.Dark)
// or
DelightSqlViewer.launch(theme = Theme.Light)
// or
DelightSqlViewer.launch(theme = Theme.Custom(myColorScheme))

Theme.Custom takes a Material 3 ColorScheme, allowing you to tailor the viewer’s UI to match your app's design.

For iOS, pass the chosen theme to the launch(theme:) method:

Button("Launch viewer in Dark theme") {
    DelightSqlViewer.shared.launch(theme: Theme.Dark())
}

Shortcuts

Android Shortcut

By default, Delight SQL Viewer adds a shortcut to your app’s launcher icon (accessible via long-press). To disable it, pass isShortcutEnabled = false during initialization:

DelightSqlViewer.init(
    provider = object : SqlDelightEnvironmentProvider() {
        override fun getDriver() = sqlDelightDriver // or roomDatabase for Room
        override fun getContext() = this@MainActivity
    },
    isShortcutEnabled = false,
)

iOS Shortcut

On iOS, the library adds a shortcut on the app icon by default. To handle shortcut actions, configure your AppDelegate or UISceneDelegate as follows:

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        configurationForConnecting connectingSceneSession: UISceneSession,
        options: UIScene.ConnectionOptions
    ) -> UISceneConfiguration {
        return ShortcutActionHandler.shared.getConfiguration(session: connectingSceneSession)
    }
}

Desktop Shortcut

By default, Delight SQL Viewer adds a “SQL Viewer” item to your app’s Taskbar/Dock context menu. To disable it, pass isShortcutEnabled = false during initialization:

DelightSqlViewer.init(
   provider = object : SqlDelightEnvironmentProvider() {
        override fun getDriver() = sqlDelightDriver // or roomDatabase for Room
    },
    isShortcutEnabled = false,
)

Excluding the Library in Release Builds

Since the viewer is primarily for debugging and development, you may want to exclude it from release builds.

Using the Stub Library

For release builds, depend on the stub module instead of the full implementation:

val isRelease = /* your logic to determine release vs. debug */

framework {
   if (isRelease) {
       // Use the stub library for release builds.
       export("ru.bartwell.delightsqlviewer:stub:2.0.0")
   } else {
       // Use the full implementation for debug builds.
       export("ru.bartwell.delightsqlviewer:runtime:2.0.0")
       export("ru.bartwell.delightsqlviewer:core:2.0.0")
       // Choose the appropriate adapter:
       export("ru.bartwell.delightsqlviewer:sqldelight-adapter:2.0.0")
       // or
       // export("ru.bartwell.delightsqlviewer:room-adapter:2.0.0")
   }
}

And in your dependencies:

dependencies {
    if (isRelease) {
        api("ru.bartwell.delightsqlviewer:stub:2.0.0")
    } else {
        api("ru.bartwell.delightsqlviewer:runtime:2.0.0")
        api("ru.bartwell.delightsqlviewer:core:2.0.0")
        // Choose the appropriate adapter:
        api("ru.bartwell.delightsqlviewer:sqldelight-adapter:2.0.0")
        // or
        // api("ru.bartwell.delightsqlviewer:room-adapter:2.0.0")
    }
}

Omitting Initialization and Launch

Alternatively, you can simply avoid calling DelightSqlViewer.init(...) and DelightSqlViewer.launch() in release builds. However, using the stub dependency is generally preferred to prevent unnecessary code inclusion.


Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request with any improvements or suggestions.


License

Copyright 2025 Artem Bazhanov

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Delight SQL Viewer is distributed under the Apache License, Version 2.0.


Happy debugging! If you have any questions or need further assistance, feel free to open an issue.

About

Delight SQL Viewer is a multiplatform library that integrates database viewing and editing into your application

Resources

License

Stars

Watchers

Forks

Packages

No packages published