drixio 1.1.7 β†’ 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,105 +1,167 @@
1
- # 🌟 Drixio - The Ultimate Zero-Dependency Database CLI & TUI
1
+ # Drixio
2
2
 
3
- **Drixio** is a lightning-fast, zero-dependency Database Manager designed entirely for your terminal. It supports **SQLite**, **PostgreSQL**, and **MySQL**.
3
+ Drixio is a lightweight database manager for local development. It provides a
4
+ terminal UI, a browser-based Studio, and scriptable CLI commands for inspecting
5
+ and changing SQLite, PostgreSQL, and MySQL databases.
4
6
 
5
- Say goodbye to heavy GUI tools like DBeaver or TablePlus. Drixio allows you to instantly view, edit, query, backup, and visually diagram your databases right from your CLI!
7
+ ## Requirements
6
8
 
7
- ## ✨ Features
9
+ - Node.js 22 or newer
10
+ - SQLite, PostgreSQL, or MySQL, depending on the database you want to use
8
11
 
9
- - **πŸ“± Interactive TUI**: A beautiful, mouse-free Terminal User Interface.
10
- - **⚑ Zero Dependencies**: Blazing fast, runs instantly via `npx`.
11
- - **πŸ› οΈ Multi-Database Support**: Connects seamlessly to SQLite, PostgreSQL, and MySQL.
12
- - **πŸ“¦ Smart Data Importer & Exporter**: Import CSV/JSON safely, or export your tables in seconds.
13
- - **🌱 Intelligent Data Seeder**: Automatically generates realistic fake data (emails, phones, dates) to populate your tables for testing.
14
- - **πŸ—ΊοΈ ER Diagram Generator**: Scans your database and generates a Mermaid ER diagram that can be instantly imported into Draw.io or viewed on GitHub!
15
- - **🧩 TypeScript Types Generator**: Instantly generate TypeScript interfaces (`.d.ts`) directly from your database schema!
12
+ ## Install and connect
16
13
 
17
- ## πŸš€ Quick Start
18
-
19
- You don't need to install anything. Just run:
14
+ Run Drixio from a project that contains a supported database:
20
15
 
21
16
  ```bash
22
17
  npx drixio
23
18
  ```
24
- Drixio will automatically scan your project for a `.env` file containing a `DATABASE_URL` (e.g., `DATABASE_URL=postgres://user:pass@localhost:5432/mydb`). If it doesn't find one, it will launch a setup wizard to help you connect!
25
19
 
26
- You can also pass a connection string directly:
27
- ```bash
28
- npx drixio "mysql://user:pass@localhost:3306/mydb"
29
- ```
20
+ Drixio looks for a database in this order:
30
21
 
31
- ---
22
+ 1. SQLite files in the project root, `prisma`, `db`, `database`, `src/db`, or
23
+ `src/database`
24
+ 2. A Prisma schema in `prisma/schema.prisma`
25
+ 3. A connection URL in `.env`
32
26
 
33
- ## πŸ› οΈ Powerful Subcommands
27
+ The following environment variable names are recognized: `DATABASE_URL`,
28
+ `DB_URL`, `POSTGRES_URL`, `POSTGRES_PRISMA_URL`, and `MYSQL_URL`.
34
29
 
35
- Drixio is not just a TUI; it comes with powerful quick-commands for your CI/CD pipelines or rapid local development.
30
+ You can also pass a connection URL directly:
36
31
 
37
- ### πŸ”Œ 1. Initialize a Local Database
38
- Don't have a database yet? Drixio can create one for you!
39
32
  ```bash
40
- npx drixio init sqlite
41
- npx drixio init postgres
42
- npx drixio init mysql
33
+ npx drixio "postgresql://user:password@localhost:5432/mydb"
34
+ npx drixio "mysql://user:password@localhost:3306/mydb"
35
+ npx drixio "file:./database.sqlite"
43
36
  ```
44
- *(For Postgres and MySQL, it connects to your local server and runs `CREATE DATABASE`, then automatically drops a configured `.env` file in your workspace!)*
45
37
 
46
- ### πŸ” 2. Quick Query
47
- Run SQL instantly and get a beautifully formatted ASCII table result.
48
- ```bash
49
- npx drixio query "SELECT * FROM users WHERE age > 18"
50
- ```
38
+ ## Interfaces
39
+
40
+ ### Interactive TUI
41
+
42
+ Running `npx drixio` opens the terminal interface. It includes database setup,
43
+ table browsing and editing, table creation and modification wizards, and a SQL
44
+ REPL.
45
+
46
+ ### Drixio Studio
47
+
48
+ Open the browser-based interface with:
51
49
 
52
- ### πŸ“₯ 3. Import Data
53
- Import massive CSV or JSON files safely. Drixio uses smart chunking to prevent memory overload.
54
50
  ```bash
55
- npx drixio import data.csv --table users
51
+ npx drixio studio
52
+ npx drixio studio "postgresql://user:password@localhost:5432/mydb"
56
53
  ```
57
54
 
58
- ### πŸ“€ 4. Export Data
59
- Export your tables to CSV or JSON.
55
+ Studio starts a local server, opens the browser automatically, and chooses an
56
+ available port starting at `51213` (or the value of `PORT`). It includes:
57
+
58
+ - **Connect Workbench**: Zero-config database setup, dialect switching (SQLite, PostgreSQL, MySQL), pre-flight overview, live connection diagnostics, and smart `DATABASE_URL` auto-fill.
59
+ - **Data View**: High-performance grid with pagination, inline editing, column sorting, search filtering, and CSV/JSON export/import.
60
+ - **Schema & Table Manager**: Visual table inspector, column editor, foreign key explorer, table creation wizards, and modern ORM generator (Prisma & Drizzle).
61
+ - **SQL Console**: Multi-tab SQL runner with intelligent autocomplete, query history, Safe Mode guard for destructive queries (DELETE/UPDATE without WHERE, DROP, TRUNCATE), and built-in SQL Snippets manager.
62
+ - **Schema Diff & Migrations**: Visual schema comparison against snapshots or external databases, live preview of Up / Down migration DDL, and one-click apply.
63
+ - **Status & Analytics**: Real-time database metrics, table size breakdown, and row distribution statistics.
64
+ - **Interactive ERD**: Pan-and-zoom entity relationship diagram with table node dragging and relation link visualization.
65
+
66
+ ## CLI commands
67
+
68
+ All commands use the database detected from the current project unless a
69
+ connection URL is supplied where noted.
70
+
71
+ | Command | Description |
72
+ | ---------------------------------------------- | ------------------------------------------------------------------------ |
73
+ | `npx drixio tables` | List all tables with row counts in terminal. `ls` is an alias. |
74
+ | `npx drixio describe [table]` | Inspect table columns, types, PKs, FKs, and indexes. `desc` is an alias. |
75
+ | `npx drixio query "<sql>"` | Run SQL and print the result as a table. |
76
+ | `npx drixio exec <file.sql>` | Execute a SQL script file. |
77
+ | `npx drixio export [table]` | Export one table or all tables as CSV or JSON. |
78
+ | `npx drixio import [file]` | Import a `.csv` or `.json` file into a table. |
79
+ | `npx drixio seed [table] [count]` | Generate realistic mock rows for a table. `mock` is an alias. |
80
+ | `npx drixio truncate [table]` | Delete all rows from a table and reset its sequence. |
81
+ | `npx drixio backup` | Create a timestamped backup directory with schema and data JSON files. |
82
+ | `npx drixio restore [dir\|file]` | Restore database from a backup directory, JSON dump, or SQL script. |
83
+ | `npx drixio diff [target]` | Compare schemas with snapshot or DB & generate Up/Down migration SQL. |
84
+ | `npx drixio snippets` | List saved SQL snippets and templates. `snip` is an alias. |
85
+ | `npx drixio run [snippet]` | Interactively execute a saved snippet or parametric query. |
86
+ | `npx drixio diagram` | Generate `drixio_schema.md` with Mermaid schema output. |
87
+ | `npx drixio generate-types` | Generate `drixio-types.d.ts` from the database schema. |
88
+ | `npx drixio generate-orm [prisma\|drizzle]` | Generate Prisma (`schema.prisma`) or Drizzle (`schema.ts`) ORM schema. |
89
+ | `npx drixio init [sqlite\|postgres\|mysql]` | Create or configure a local database and save `DATABASE_URL` to `.env`. |
90
+ | `npx drixio drop-db [sqlite\|postgres\|mysql]` | Permanently delete a local database after confirmation. |
91
+
92
+ ### Common options
93
+
60
94
  ```bash
95
+ npx drixio tables
96
+ npx drixio tables --json
97
+ npx drixio describe users
61
98
  npx drixio export users --format csv
62
- npx drixio export * --format json --schema-only
99
+ npx drixio export --format json --schema-only
100
+ npx drixio import data.json --table users
101
+ npx drixio diff --snapshot
102
+ npx drixio diff "postgres://..." --apply
103
+ npx drixio run snip_recent_records
104
+ npx drixio --version
105
+ npx drixio --help
63
106
  ```
64
107
 
65
- ### 🌱 5. Generate Fake Data (Seed)
66
- Need 500 fake users for testing? Easy. Drixio intelligently analyzes your column names and types to generate realistic data.
67
- ```bash
68
- npx drixio seed users 500
69
- ```
108
+ - `-v, --version` prints the drixio version.
109
+ - `--help` displays command help and options.
110
+ - `--json` outputs result as structured JSON (supported by `tables`, `describe`).
111
+ - `--format csv|json` selects the export format.
112
+ - `--schema-only` exports table definitions without data.
113
+ - `--table <name>` selects the destination table for imports or ORM generation.
114
+ - `--out <file>` specifies output file path for ORM schemas, diff SQL, or snapshots.
115
+ - `--snapshot` exports a schema snapshot JSON for git tracking or offline comparison.
116
+ - `--apply` automatically executes and applies generated migration SQL to the current database.
117
+ - `--reverse` generates rollback (down) migration SQL.
118
+ - `--print` prints generated ORM or schema directly to terminal.
119
+ - `--force`, `-y` skips confirmation prompts during restore or database drops.
70
120
 
71
- ### πŸ—ΊοΈ 6. Generate ER Diagram
72
- Automatically generates a `drixio_schema.md` containing a Mermaid.js diagram of your database.
73
- ```bash
74
- npx drixio diagram
75
- ```
76
- *Tip: Paste the output into Draw.io (Arrange > Insert > Advanced > Mermaid) for a stunning visual layout!*
121
+ Exports are written to `drixio_exports/` in the current directory. Backups are
122
+ written to a timestamped `drixio_backup_<timestamp>/` directory. Snapshots and custom
123
+ snippets are stored in `.drixio/`.
124
+
125
+ ## Local database setup
126
+
127
+ SQLite needs no server:
77
128
 
78
- ### 🧩 7. Generate TypeScript Interfaces
79
- Tired of manually writing types? Auto-generate them from your schema!
80
129
  ```bash
81
- npx drixio generate-types
130
+ npx drixio init sqlite
131
+ npx drixio init sqlite my-app
82
132
  ```
83
- *(Outputs `drixio-types.d.ts` with all your table interfaces)*
84
133
 
85
- ### πŸ“œ 8. Execute SQL Script
86
- Run entire `.sql` files instantly. Perfect for database migrations.
134
+ For PostgreSQL and MySQL, `init` asks for local server credentials, creates the
135
+ database, and writes the resulting connection URL to `.env`:
136
+
87
137
  ```bash
88
- npx drixio exec ./migrations/init.sql
138
+ npx drixio init postgres mydb
139
+ npx drixio init mysql mydb
89
140
  ```
90
141
 
91
- ### πŸ“¦ 9. Database Backup
92
- Backup your entire database. For SQLite, it performs a secure binary copy. For Postgres/MySQL, it dumps schema and data into JSON.
142
+ `drop-db` permanently removes a SQLite file or drops a PostgreSQL/MySQL
143
+ database. `truncate` permanently removes all rows from one table. Both commands
144
+ ask for confirmation; use them carefully.
145
+
146
+ ## Development
147
+
148
+ Install dependencies and run the project locally:
149
+
93
150
  ```bash
94
- npx drixio backup
151
+ pnpm install
152
+ pnpm dev
153
+ pnpm dev:studio
95
154
  ```
96
155
 
97
- ## ❓ Help
98
- To view all commands and options:
156
+ Build both the CLI and Studio bundles:
157
+
99
158
  ```bash
100
- npx drixio --help
159
+ pnpm build
101
160
  ```
102
161
 
103
- ---
162
+ The package is published as `drixio`, and `prepublishOnly` builds both bundles
163
+ before publishing.
164
+
165
+ ## License
104
166
 
105
- **Built with ❀️ for Developers who love the Terminal.**
167
+ MIT