Flocon/docs/database.md
Florent CHAMPIGNY 20b7b7b29c
Refact doc dashboard (#470)
Co-authored-by: Florent Champigny <florent@bere.al>
2025-12-26 17:58:02 +01:00

63 lines
No EOL
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 🧩 Database Explorer & SQL Editor
<img width="1726" height="1080" alt="Screenshot 2025-10-14 at 23 40 58" src="https://github.com/user-attachments/assets/47360e06-43af-4713-b0ed-a6728a6b49ad" />
<img width="1728" height="1077" alt="Screenshot 2025-10-14 at 23 44 16" src="https://github.com/user-attachments/assets/f351970f-0511-4b54-af5e-55dcd209f2e2" />
Flocon gives you direct access to your apps **local databases** (SQLite, Room, SQLDelight, etc.), with a clean interface for exploring schemas and querying data.
Key capabilities include:
- **Automatic detection** of all SQLite databases on Android.
- Listing all tables and their schemas.
- Running **custom SQL queries** with syntax highlighting.
- Auto-updating queries and saving favorites.
- Generating `INSERT` and `DELETE` queries automatically.
#### Android (Automatic Detection)
On Android, Flocon automatically scans your app's internal storage and lists all SQLite databases. You don't need additional configuration to see them in the desktop app.
#### Manual Registration (Android)
If you want to use a custom display name or register an **in-memory database**, you can use `floconRegisterDatabase`:
```kotlin
// Register an In-Memory Room Database
val dogDatabase = Room.inMemoryDatabaseBuilder(context, DogDatabase::class.java).build()
floconRegisterDatabase(
displayName = "In-Memory Dogs",
openHelper = dogDatabase.openHelper
)
```
#### Multiplatform (Desktop & iOS)
For Kotlin Multiplatform projects (Desktop and iOS), you must provide the absolute path to the database file:
```kotlin
// On Desktop
val dbFile = File(System.getProperty("java.io.tmpdir"), "app_database.db")
floconRegisterDatabase(
displayName = "App DB",
absolutePath = dbFile.absolutePath,
)
```
```kotlin
// On iOS
val dbPath = "${documentDirectory()}/app_database.db"
floconRegisterDatabase(
displayName = "App DB",
absolutePath = dbPath
)
```
#### SQL Workspace
The Flocon Desktop app provides a full SQL workspace where you can:
1. **Explore**: See all tables and their columns.
2. **Query**: Write any SQL query and see the results in a formatted table.
3. **Favorites**: Save your most used queries for quick access later.
4. **Toolbox**: Quickly generate common SQL statements from the UI.