flashorm 2.4.1b0.dev0__tar.gz → 2.4.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flashorm
3
- Version: 2.4.1b0.dev0
3
+ Version: 2.4.3
4
4
  Summary: A powerful, database-agnostic ORM with multi-database support and type-safe code generation
5
5
  Home-page: https://github.com/Lumos-Labs-HQ/flash
6
6
  Author: Rana718
@@ -74,7 +74,7 @@ This creates:
74
74
 
75
75
  ```
76
76
  your-project/
77
- ├── flash.config.json
77
+ ├── flash.toml
78
78
  ├── .env
79
79
  └── db/
80
80
  ├── schema/
@@ -233,7 +233,7 @@ flash studio
233
233
  flash studio --port 3000
234
234
 
235
235
  # Connect to any database directly
236
- flash studio --db "postgresql://user:pass@localhost:5432/mydb"
236
+ flash studio "postgresql://user:pass@localhost:5432/mydb"
237
237
 
238
238
  # Launch without opening browser
239
239
  flash studio --browser=false
@@ -347,27 +347,22 @@ flash <command> --help
347
347
 
348
348
  ## ⚙️ Configuration
349
349
 
350
- **flash.config.json**
350
+ **flash.toml**
351
351
 
352
- ```json
353
- {
354
- "version": "2",
355
- "schema_path": "db/schema/schema.sql",
356
- "queries": "db/queries/",
357
- "migrations_path": "db/migrations",
358
- "export_path": "db/export",
359
- "database": {
360
- "provider": "postgresql",
361
- "url_env": "DATABASE_URL"
362
- },
363
- "gen": {
364
-
365
- "python": {
366
- "enabled": true,
367
- "async": false
368
- }
369
- }
370
- }
352
+ ```toml
353
+ version = "2"
354
+ schema_path = "db/schema/schema.sql"
355
+ queries = "db/queries/"
356
+ migrations_path = "db/migrations"
357
+ export_path = "db/export"
358
+
359
+ [database]
360
+ provider = "postgresql"
361
+ url_env = "DATABASE_URL"
362
+
363
+ [gen.python]
364
+ enabled = true
365
+ async = false
371
366
  ```
372
367
 
373
368
  **Python Generation Options:**
@@ -1,576 +1,571 @@
1
- # FlashORM
2
-
3
- A powerful, database-agnostic migration CLI tool built in Go with multi-database support, visual database editor (FlashORM Studio), and type-safe code generation for JavaScript/TypeScript.
4
-
5
- ## ✨ Features
6
-
7
- - 🎨 **FlashORM Studio**: Visual database editor with React-based schema visualization
8
- - 🗃️ **Multi-Database Support**: PostgreSQL, MySQL, SQLite
9
- - 🔄 **Migration Management**: Create, apply, and track migrations
10
- - 🔒 **Safe Migration System**: Transaction-based execution with automatic rollback
11
- - 📤 **Smart Export System**: Multiple formats (JSON, CSV, SQLite)
12
- - 🔧 **Type-Safe Code Generation**: Generate fully typed JavaScript/TypeScript code
13
- - ⚡ **Blazing Fast**: 2.5x faster than Drizzle, 10x faster than Prisma
14
- - 💻 **Raw SQL Execution**: Execute SQL files or inline queries
15
- - 🎯 **Prisma-like Commands**: Familiar CLI interface
16
-
17
- ## 📊 Performance
18
-
19
- FlashORM significantly outperforms popular ORMs in real-world scenarios:
20
-
21
- | Operation | FlashORM | SQLAlchemy |
22
- | ------------------------------------------ | ---------- | ----------- |
23
- | Insert 1000 Users | **16ms** | **299ms** |
24
- | Insert 10 Cat + 5K Posts + 15K Comments | **440ms** | **1333ms** |
25
- | Complex Query x500 | **1199ms** | **10627ms** |
26
- | Mixed Workload x1000 (75% read, 25% write) | **248ms** | **645ms** |
27
- | Stress Test Simple Query x2000 | **338ms** | **984ms** |
28
- | **TOTAL** | **2241ms** | **13888ms** |
29
-
30
- ## 🚀 Installation
31
-
32
- Install from PyPI (recommended):
33
-
34
- ```bash
35
- pip install flashorm
36
- ```
37
-
38
- ## 🏁 Quick Start
39
-
40
- ### 1. Initialize Project
41
-
42
- ```bash
43
- flash init --postgresql # or --mysql, --sqlite
44
- ```
45
-
46
- This creates:
47
-
48
- ```
49
- your-project/
50
- ├── flash.config.json
51
- ├── .env
52
- └── db/
53
- ├── schema/
54
- │ └── schema.sql
55
- └── queries/
56
- └── users.sql
57
- ```
58
-
59
- ### 2. Configure Database
60
-
61
- ```bash
62
- # .env file
63
- DATABASE_URL=postgresql://user:password@localhost:5432/mydb
64
- ```
65
-
66
- ### 3. Define Schema
67
-
68
- **db/schema/schema.sql**
69
-
70
- ```sql
71
- CREATE TABLE users (
72
- id SERIAL PRIMARY KEY,
73
- name VARCHAR(255) NOT NULL,
74
- email VARCHAR(255) UNIQUE NOT NULL,
75
- created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
76
- updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
77
- );
78
- ```
79
-
80
- ### 4. Write Queries
81
-
82
- **db/queries/users.sql**
83
-
84
- ```sql
85
- -- name: GetUser :one
86
- SELECT id, name, email, created_at, updated_at FROM users
87
- WHERE id = $1 LIMIT 1;
88
-
89
- -- name: CreateUser :one
90
- INSERT INTO users (name, email)
91
- VALUES ($1, $2)
92
- RETURNING id, name, email, created_at, updated_at;
93
-
94
- -- name: ListUsers :many
95
- SELECT id, name, email, created_at, updated_at FROM users
96
- ORDER BY created_at DESC;
97
-
98
- -- name: UpdateUser :one
99
- UPDATE users
100
- SET name = $2, email = $3, updated_at = NOW()
101
- WHERE id = $1
102
- RETURNING id, name, email, created_at, updated_at;
103
-
104
- -- name: DeleteUser :exec
105
- DELETE FROM users WHERE id = $1;
106
- ```
107
-
108
- ### 5. Create Migration
109
-
110
- ```bash
111
- flash migrate "create users table"
112
- ```
113
-
114
- ### 6. Apply Migration
115
-
116
- ```bash
117
- flash apply
118
- ```
119
-
120
- ### 7. Generate Type-Safe Code
121
-
122
- ```bash
123
- flash gen
124
- ```
125
-
126
- **Generated Table Types (flash_gen/models.py)**
127
-
128
- ```py
129
-
130
- # Code generated by FlashORM. DO NOT EDIT.
131
-
132
- from dataclasses import dataclass
133
- from typing import Optional, Literal
134
- from datetime import datetime
135
- from decimal import Decimal
136
-
137
- @dataclass
138
- class Users:
139
- id: int
140
- name: str
141
- email: str
142
- created_at: datetime
143
- updated_at: datetime
144
-
145
-
146
- ```
147
-
148
- ### 8. Use in Your Code
149
-
150
- **Async Example (default)**
151
-
152
- ```python
153
- import asyncio
154
- import asyncpg
155
- import os
156
- from flash_gen.database import new
157
-
158
- DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql://postgres:postgres@localhost:5432/FlashORM_test')
159
-
160
- async def main():
161
- pool = await asyncpg.create_pool(DATABASE_URL)
162
-
163
- db = new(pool)
164
-
165
- newuser = await db.create_user('jack', 'jack@gmail.com')
166
- print('New user:', newuser)
167
-
168
- await pool.close()
169
-
170
- if __name__ == '__main__':
171
- asyncio.run(main())
172
- ```
173
-
174
- **Sync Example (set `"async": false` in config)**
175
-
176
- ```python
177
- import psycopg2
178
- import os
179
- from flash_gen.database import new
180
-
181
- DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql://postgres:postgres@localhost:5432/FlashORM_test')
182
-
183
- def main():
184
- conn = psycopg2.connect(DATABASE_URL)
185
-
186
- db = new(conn)
187
-
188
- newuser = db.create_user('jack', 'jack@gmail.com')
189
- print('New user:', newuser)
190
-
191
- conn.close()
192
-
193
- if __name__ == '__main__':
194
- main()
195
- ```
196
-
197
- ## 📋 All Commands
198
-
199
- ### Visual Database Editor
200
-
201
- ```bash
202
- # Launch FlashORM Studio (web-based database editor)
203
- flash studio
204
-
205
- # Launch on custom port
206
- flash studio --port 3000
207
-
208
- # Connect to any database directly
209
- flash studio --db "postgresql://user:pass@localhost:5432/mydb"
210
-
211
- # Launch without opening browser
212
- flash studio --browser=false
213
- ```
214
-
215
- **Studio Features:**
216
-
217
- - 📊 **Data Browser**: View and edit table data with inline editing
218
- - 💻 **SQL Editor**: Execute queries with CodeMirror syntax highlighting
219
- - 🎨 **Schema Visualization**: Interactive database diagram with React + ReactFlow
220
- - 🔍 **Search & Filter**: Search across all tables
221
- - ⚡ **Real-time Updates**: See changes immediately
222
-
223
- ### Project Setup
224
-
225
- ```bash
226
- # Initialize new project
227
- flash init --postgresql
228
- flash init --mysql
229
- flash init --sqlite
230
- ```
231
-
232
- ### Migrations
233
-
234
- ```bash
235
- # Create new migration
236
- flash migrate "migration name"
237
-
238
- # Create empty migration
239
- flash migrate "custom migration" --empty
240
-
241
- # Apply all pending migrations
242
- flash apply
243
-
244
- # Apply with force (skip confirmations)
245
- flash apply --force
246
-
247
- # Check migration status
248
- flash status
249
- ```
250
-
251
- ### Code Generation
252
-
253
- ```bash
254
- # Generate type-safe code
255
- flash gen
256
- ```
257
-
258
- ### Schema Management
259
-
260
- ```bash
261
- # Pull schema from existing database
262
- flash pull
263
-
264
- # Pull with backup
265
- flash pull --backup
266
-
267
- # Pull to custom file
268
- flash pull --output custom-schema.sql
269
- ```
270
-
271
- ### Database Export
272
-
273
- ```bash
274
- # Export as JSON (default)
275
- flash export
276
- flash export --json
277
-
278
- # Export as CSV
279
- flash export --csv
280
-
281
- # Export as SQLite
282
- flash export --sqlite
283
- ```
284
-
285
- ### Database Operations
286
-
287
- ```bash
288
- # Reset database (destructive!)
289
- flash reset
290
-
291
- # Reset with force
292
- flash reset --force
293
-
294
- # Execute raw SQL file
295
- flash raw script.sql
296
- flash raw migrations/seed.sql
297
-
298
- # Execute inline SQL query
299
- flash raw -q "SELECT * FROM users WHERE active = true"
300
- flash raw "SELECT COUNT(*) FROM orders"
301
-
302
- # Force file mode
303
- flash raw --file queries/complex.sql
304
- ```
305
-
306
- ### Help & Info
307
-
308
- ```bash
309
- # Launch FlashORM Studio
310
- flash studio
311
-
312
- # Show version
313
- flash --version
314
- flash -v
315
-
316
- # Show help
317
- flash --help
318
- flash <command> --help
319
- ```
320
-
321
- ## ⚙️ Configuration
322
-
323
- **flash.config.json**
324
-
325
- ```json
326
- {
327
- "version": "2",
328
- "schema_path": "db/schema/schema.sql",
329
- "queries": "db/queries/",
330
- "migrations_path": "db/migrations",
331
- "export_path": "db/export",
332
- "database": {
333
- "provider": "postgresql",
334
- "url_env": "DATABASE_URL"
335
- },
336
- "gen": {
337
-
338
- "python": {
339
- "enabled": true,
340
- "async": false
341
- }
342
- }
343
- }
344
- ```
345
-
346
- **Python Generation Options:**
347
-
348
- - `async`: Set to `true` for async/await code generation (default), `false` for synchronous code generation.
349
-
350
- ## 🎨 PostgreSQL ENUM Support
351
-
352
- **Schema with ENUMs**
353
-
354
- ```sql
355
- CREATE TYPE user_role AS ENUM ('admin', 'user', 'guest');
356
-
357
- CREATE TABLE users (
358
- id SERIAL PRIMARY KEY,
359
- name VARCHAR(255) NOT NULL,
360
- role user_role NOT NULL DEFAULT 'user'
361
- );
362
- ```
363
-
364
- ## 🔒 Safe Migrations
365
-
366
- Every migration runs in a transaction with automatic rollback on failure:
367
-
368
- ```bash
369
- $ flash apply
370
- 📦 Applying 2 migration(s)...
371
- [1/2] 20251103_create_users
372
- ✅ Applied
373
- [2/2] 20251103_add_email_index
374
- ✅ Applied
375
- ✅ All migrations applied successfully
376
- ```
377
-
378
- If a migration fails:
379
-
380
- ```bash
381
- Failed at migration: 20251103_bad_migration
382
- Error: syntax error at or near "INVALID"
383
- Transaction rolled back. Fix the error and run 'flash apply' again.
384
- ```
385
-
386
- ## 🛡️ Conflict Detection
387
-
388
- FlashORM automatically detects schema conflicts:
389
-
390
- ```bash
391
- ⚠️ Migration conflicts detected:
392
- - Table 'users' already exists
393
- - Column 'email' conflicts with existing column
394
-
395
- Reset database to resolve conflicts? (y/n): y
396
- Create export before applying? (y/n): y
397
- 📦 Creating export...
398
- ✅ Export created successfully
399
- 🔄 Resetting database and applying all migrations...
400
- ```
401
-
402
- ## 📤 Export Formats
403
-
404
- ### JSON Export
405
-
406
- ```bash
407
- flash export --json
408
- ```
409
-
410
- ```json
411
- {
412
- "timestamp": "2025-11-03 16:30:00",
413
- "version": "1.0",
414
- "tables": {
415
- "users": [{ "id": 1, "name": "Alice", "email": "alice@example.com" }]
416
- }
417
- }
418
- ```
419
-
420
- ### CSV Export
421
-
422
- ```bash
423
- flash export --csv
424
- ```
425
-
426
- Creates directory with individual CSV files per table.
427
-
428
- ### SQLite Export
429
-
430
- ```bash
431
- flash export --sqlite
432
- ```
433
-
434
- Creates portable `.db` file.
435
-
436
- ## 🎨 FlashORM Studio
437
-
438
- Launch the visual database editor:
439
-
440
- ```bash
441
- flash studio
442
- ```
443
-
444
- Open http://localhost:5555 (or your custom port)
445
-
446
- **Features:**
447
-
448
- ### 1. Data Browser (`/`)
449
-
450
- - View all tables in sidebar
451
- - Click any table to view/edit data
452
- - Double-click cells for inline editing
453
- - Add/delete rows with intuitive modals
454
- - Pagination (50 rows per page)
455
- - Search across tables
456
- - Foreign key hints
457
-
458
- ### 2. SQL Editor (`/sql`)
459
-
460
- - Execute custom SQL queries
461
- - CodeMirror editor with syntax highlighting
462
- - Press Ctrl+Enter to run queries
463
- - Export results to CSV
464
- - Resizable split-pane interface
465
- - Query history
466
-
467
- ### 3. Schema Visualization (`/schema`)
468
-
469
- - Interactive database diagram
470
- - React + ReactFlow rendering
471
- - Automatic layout with Dagre algorithm
472
- - Drag and drop tables
473
- - Zoom and pan controls
474
- - Foreign key relationship arrows
475
- - MiniMap for navigation
476
-
477
- ## 💻 Raw SQL Execution
478
-
479
- Execute SQL files or inline queries:
480
-
481
- ```bash
482
- # Execute SQL file
483
- flash raw script.sql
484
-
485
- # Execute inline query
486
- flash raw -q "SELECT * FROM users LIMIT 10"
487
-
488
- # Auto-detection (file if exists, otherwise query)
489
- flash raw "SELECT COUNT(*) FROM orders"
490
- ```
491
-
492
- **Features:**
493
-
494
- - ✅ Beautiful table output for SELECT queries
495
- - ✅ Multi-statement execution
496
- - ✅ Transaction support
497
- - ✅ Auto-detection of file vs query
498
- - Formatted error messages
499
-
500
- **Example Output:**
501
-
502
- ```bash
503
- $ flash raw -q "SELECT id, name, email FROM users LIMIT 3"
504
-
505
- 🎯 Database: postgresql
506
-
507
- Executing query...
508
- ✅ Query executed successfully
509
- 📊 3 row(s) returned
510
-
511
- ┌────┬────────────┬─────────────────────┐
512
- │ id │ name │ email │
513
- ├────┼────────────┼─────────────────────┤
514
- │ 1 │ Alice │ alice@example.com │
515
- │ 2 │ Bob │ bob@example.com │
516
- │ 3 │ Charlie │ charlie@example.com │
517
- └────┴────────────┴─────────────────────┘
518
- ```
519
-
520
- d
521
-
522
- ## 📚 Examples
523
-
524
- Check out complete examples:
525
-
526
- - [Python Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/python)
527
- - [TypeScript Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/ts)
528
- - [Go Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/go)
529
-
530
- ## 🐛 Troubleshooting
531
-
532
- ### Bun Postinstall Blocked
533
-
534
- ```bash
535
- bun pm trust flashorm
536
- ```
537
-
538
- ### Binary Not Found
539
-
540
- ```bash
541
- npm install -g flashorm --force
542
- ```
543
-
544
- ### Database Connection Failed
545
-
546
- Check your `DATABASE_URL` in `.env` file.
547
-
548
- ### Studio Not Loading
549
-
550
- Make sure port 5555 is not in use, or specify a different port:
551
-
552
- ```bash
553
- flash studio --port 3000
554
- ```
555
-
556
- ## 📖 Documentation
557
-
558
- - [Full Documentation](https://github.com/Lumos-Labs-HQ/flash)
559
- - [How It Works](https://github.com/Lumos-Labs-HQ/flash/blob/main/docs/HOW_IT_WORKS.md)
560
- - [Technology Stack](https://github.com/Lumos-Labs-HQ/flash/blob/main/docs/TECHNOLOGY_STACK.md)
561
- - [Contributing](https://github.com/Lumos-Labs-HQ/flash/blob/main/docs/CONTRIBUTING.md)
562
-
563
- ## 🌟 Key Highlights
564
-
565
- - **Visual Database Editor**: Manage your database visually with FlashORM Studio
566
- - **Raw SQL Support**: Execute SQL files or queries directly from CLI
567
- - **Type-Safe**: Full TypeScript support with generated types
568
- - **Fast**: 2.5x-10x faster than popular ORMs
569
- - **Multi-DB**: PostgreSQL, MySQL, and SQLite support
570
- - **Zero Config**: Works out of the box with sensible defaults
571
-
572
- ## 📄 License
573
-
574
- MIT License - see [LICENSE](https://github.com/Lumos-Labs-HQ/flash/blob/main/LICENSE)
575
-
576
- ---
1
+ # FlashORM
2
+
3
+ A powerful, database-agnostic migration CLI tool built in Go with multi-database support, visual database editor (FlashORM Studio), and type-safe code generation for JavaScript/TypeScript.
4
+
5
+ ## ✨ Features
6
+
7
+ - 🎨 **FlashORM Studio**: Visual database editor with React-based schema visualization
8
+ - 🗃️ **Multi-Database Support**: PostgreSQL, MySQL, SQLite
9
+ - 🔄 **Migration Management**: Create, apply, and track migrations
10
+ - 🔒 **Safe Migration System**: Transaction-based execution with automatic rollback
11
+ - 📤 **Smart Export System**: Multiple formats (JSON, CSV, SQLite)
12
+ - 🔧 **Type-Safe Code Generation**: Generate fully typed JavaScript/TypeScript code
13
+ - ⚡ **Blazing Fast**: 2.5x faster than Drizzle, 10x faster than Prisma
14
+ - 💻 **Raw SQL Execution**: Execute SQL files or inline queries
15
+ - 🎯 **Prisma-like Commands**: Familiar CLI interface
16
+
17
+ ## 📊 Performance
18
+
19
+ FlashORM significantly outperforms popular ORMs in real-world scenarios:
20
+
21
+ | Operation | FlashORM | SQLAlchemy |
22
+ | ------------------------------------------ | ---------- | ----------- |
23
+ | Insert 1000 Users | **16ms** | **299ms** |
24
+ | Insert 10 Cat + 5K Posts + 15K Comments | **440ms** | **1333ms** |
25
+ | Complex Query x500 | **1199ms** | **10627ms** |
26
+ | Mixed Workload x1000 (75% read, 25% write) | **248ms** | **645ms** |
27
+ | Stress Test Simple Query x2000 | **338ms** | **984ms** |
28
+ | **TOTAL** | **2241ms** | **13888ms** |
29
+
30
+ ## 🚀 Installation
31
+
32
+ Install from PyPI (recommended):
33
+
34
+ ```bash
35
+ pip install flashorm
36
+ ```
37
+
38
+ ## 🏁 Quick Start
39
+
40
+ ### 1. Initialize Project
41
+
42
+ ```bash
43
+ flash init --postgresql # or --mysql, --sqlite
44
+ ```
45
+
46
+ This creates:
47
+
48
+ ```
49
+ your-project/
50
+ ├── flash.toml
51
+ ├── .env
52
+ └── db/
53
+ ├── schema/
54
+ │ └── schema.sql
55
+ └── queries/
56
+ └── users.sql
57
+ ```
58
+
59
+ ### 2. Configure Database
60
+
61
+ ```bash
62
+ # .env file
63
+ DATABASE_URL=postgresql://user:password@localhost:5432/mydb
64
+ ```
65
+
66
+ ### 3. Define Schema
67
+
68
+ **db/schema/schema.sql**
69
+
70
+ ```sql
71
+ CREATE TABLE users (
72
+ id SERIAL PRIMARY KEY,
73
+ name VARCHAR(255) NOT NULL,
74
+ email VARCHAR(255) UNIQUE NOT NULL,
75
+ created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
76
+ updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
77
+ );
78
+ ```
79
+
80
+ ### 4. Write Queries
81
+
82
+ **db/queries/users.sql**
83
+
84
+ ```sql
85
+ -- name: GetUser :one
86
+ SELECT id, name, email, created_at, updated_at FROM users
87
+ WHERE id = $1 LIMIT 1;
88
+
89
+ -- name: CreateUser :one
90
+ INSERT INTO users (name, email)
91
+ VALUES ($1, $2)
92
+ RETURNING id, name, email, created_at, updated_at;
93
+
94
+ -- name: ListUsers :many
95
+ SELECT id, name, email, created_at, updated_at FROM users
96
+ ORDER BY created_at DESC;
97
+
98
+ -- name: UpdateUser :one
99
+ UPDATE users
100
+ SET name = $2, email = $3, updated_at = NOW()
101
+ WHERE id = $1
102
+ RETURNING id, name, email, created_at, updated_at;
103
+
104
+ -- name: DeleteUser :exec
105
+ DELETE FROM users WHERE id = $1;
106
+ ```
107
+
108
+ ### 5. Create Migration
109
+
110
+ ```bash
111
+ flash migrate "create users table"
112
+ ```
113
+
114
+ ### 6. Apply Migration
115
+
116
+ ```bash
117
+ flash apply
118
+ ```
119
+
120
+ ### 7. Generate Type-Safe Code
121
+
122
+ ```bash
123
+ flash gen
124
+ ```
125
+
126
+ **Generated Table Types (flash_gen/models.py)**
127
+
128
+ ```py
129
+
130
+ # Code generated by FlashORM. DO NOT EDIT.
131
+
132
+ from dataclasses import dataclass
133
+ from typing import Optional, Literal
134
+ from datetime import datetime
135
+ from decimal import Decimal
136
+
137
+ @dataclass
138
+ class Users:
139
+ id: int
140
+ name: str
141
+ email: str
142
+ created_at: datetime
143
+ updated_at: datetime
144
+
145
+
146
+ ```
147
+
148
+ ### 8. Use in Your Code
149
+
150
+ **Async Example (default)**
151
+
152
+ ```python
153
+ import asyncio
154
+ import asyncpg
155
+ import os
156
+ from flash_gen.database import new
157
+
158
+ DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql://postgres:postgres@localhost:5432/FlashORM_test')
159
+
160
+ async def main():
161
+ pool = await asyncpg.create_pool(DATABASE_URL)
162
+
163
+ db = new(pool)
164
+
165
+ newuser = await db.create_user('jack', 'jack@gmail.com')
166
+ print('New user:', newuser)
167
+
168
+ await pool.close()
169
+
170
+ if __name__ == '__main__':
171
+ asyncio.run(main())
172
+ ```
173
+
174
+ **Sync Example (set `"async": false` in config)**
175
+
176
+ ```python
177
+ import psycopg2
178
+ import os
179
+ from flash_gen.database import new
180
+
181
+ DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql://postgres:postgres@localhost:5432/FlashORM_test')
182
+
183
+ def main():
184
+ conn = psycopg2.connect(DATABASE_URL)
185
+
186
+ db = new(conn)
187
+
188
+ newuser = db.create_user('jack', 'jack@gmail.com')
189
+ print('New user:', newuser)
190
+
191
+ conn.close()
192
+
193
+ if __name__ == '__main__':
194
+ main()
195
+ ```
196
+
197
+ ## 📋 All Commands
198
+
199
+ ### Visual Database Editor
200
+
201
+ ```bash
202
+ # Launch FlashORM Studio (web-based database editor)
203
+ flash studio
204
+
205
+ # Launch on custom port
206
+ flash studio --port 3000
207
+
208
+ # Connect to any database directly
209
+ flash studio "postgresql://user:pass@localhost:5432/mydb"
210
+
211
+ # Launch without opening browser
212
+ flash studio --browser=false
213
+ ```
214
+
215
+ **Studio Features:**
216
+
217
+ - 📊 **Data Browser**: View and edit table data with inline editing
218
+ - 💻 **SQL Editor**: Execute queries with CodeMirror syntax highlighting
219
+ - 🎨 **Schema Visualization**: Interactive database diagram with React + ReactFlow
220
+ - 🔍 **Search & Filter**: Search across all tables
221
+ - ⚡ **Real-time Updates**: See changes immediately
222
+
223
+ ### Project Setup
224
+
225
+ ```bash
226
+ # Initialize new project
227
+ flash init --postgresql
228
+ flash init --mysql
229
+ flash init --sqlite
230
+ ```
231
+
232
+ ### Migrations
233
+
234
+ ```bash
235
+ # Create new migration
236
+ flash migrate "migration name"
237
+
238
+ # Create empty migration
239
+ flash migrate "custom migration" --empty
240
+
241
+ # Apply all pending migrations
242
+ flash apply
243
+
244
+ # Apply with force (skip confirmations)
245
+ flash apply --force
246
+
247
+ # Check migration status
248
+ flash status
249
+ ```
250
+
251
+ ### Code Generation
252
+
253
+ ```bash
254
+ # Generate type-safe code
255
+ flash gen
256
+ ```
257
+
258
+ ### Schema Management
259
+
260
+ ```bash
261
+ # Pull schema from existing database
262
+ flash pull
263
+
264
+ # Pull with backup
265
+ flash pull --backup
266
+
267
+ # Pull to custom file
268
+ flash pull --output custom-schema.sql
269
+ ```
270
+
271
+ ### Database Export
272
+
273
+ ```bash
274
+ # Export as JSON (default)
275
+ flash export
276
+ flash export --json
277
+
278
+ # Export as CSV
279
+ flash export --csv
280
+
281
+ # Export as SQLite
282
+ flash export --sqlite
283
+ ```
284
+
285
+ ### Database Operations
286
+
287
+ ```bash
288
+ # Reset database (destructive!)
289
+ flash reset
290
+
291
+ # Reset with force
292
+ flash reset --force
293
+
294
+ # Execute raw SQL file
295
+ flash raw script.sql
296
+ flash raw migrations/seed.sql
297
+
298
+ # Execute inline SQL query
299
+ flash raw -q "SELECT * FROM users WHERE active = true"
300
+ flash raw "SELECT COUNT(*) FROM orders"
301
+
302
+ # Force file mode
303
+ flash raw --file queries/complex.sql
304
+ ```
305
+
306
+ ### Help & Info
307
+
308
+ ```bash
309
+ # Launch FlashORM Studio
310
+ flash studio
311
+
312
+ # Show version
313
+ flash --version
314
+ flash -v
315
+
316
+ # Show help
317
+ flash --help
318
+ flash <command> --help
319
+ ```
320
+
321
+ ## ⚙️ Configuration
322
+
323
+ **flash.toml**
324
+
325
+ ```toml
326
+ version = "2"
327
+ schema_path = "db/schema/schema.sql"
328
+ queries = "db/queries/"
329
+ migrations_path = "db/migrations"
330
+ export_path = "db/export"
331
+
332
+ [database]
333
+ provider = "postgresql"
334
+ url_env = "DATABASE_URL"
335
+
336
+ [gen.python]
337
+ enabled = true
338
+ async = false
339
+ ```
340
+
341
+ **Python Generation Options:**
342
+
343
+ - `async`: Set to `true` for async/await code generation (default), `false` for synchronous code generation.
344
+
345
+ ## 🎨 PostgreSQL ENUM Support
346
+
347
+ **Schema with ENUMs**
348
+
349
+ ```sql
350
+ CREATE TYPE user_role AS ENUM ('admin', 'user', 'guest');
351
+
352
+ CREATE TABLE users (
353
+ id SERIAL PRIMARY KEY,
354
+ name VARCHAR(255) NOT NULL,
355
+ role user_role NOT NULL DEFAULT 'user'
356
+ );
357
+ ```
358
+
359
+ ## 🔒 Safe Migrations
360
+
361
+ Every migration runs in a transaction with automatic rollback on failure:
362
+
363
+ ```bash
364
+ $ flash apply
365
+ 📦 Applying 2 migration(s)...
366
+ [1/2] 20251103_create_users
367
+ ✅ Applied
368
+ [2/2] 20251103_add_email_index
369
+ Applied
370
+ All migrations applied successfully
371
+ ```
372
+
373
+ If a migration fails:
374
+
375
+ ```bash
376
+ ❌ Failed at migration: 20251103_bad_migration
377
+ Error: syntax error at or near "INVALID"
378
+ Transaction rolled back. Fix the error and run 'flash apply' again.
379
+ ```
380
+
381
+ ## 🛡️ Conflict Detection
382
+
383
+ FlashORM automatically detects schema conflicts:
384
+
385
+ ```bash
386
+ ⚠️ Migration conflicts detected:
387
+ - Table 'users' already exists
388
+ - Column 'email' conflicts with existing column
389
+
390
+ Reset database to resolve conflicts? (y/n): y
391
+ Create export before applying? (y/n): y
392
+ 📦 Creating export...
393
+ Export created successfully
394
+ 🔄 Resetting database and applying all migrations...
395
+ ```
396
+
397
+ ## 📤 Export Formats
398
+
399
+ ### JSON Export
400
+
401
+ ```bash
402
+ flash export --json
403
+ ```
404
+
405
+ ```json
406
+ {
407
+ "timestamp": "2025-11-03 16:30:00",
408
+ "version": "1.0",
409
+ "tables": {
410
+ "users": [{ "id": 1, "name": "Alice", "email": "alice@example.com" }]
411
+ }
412
+ }
413
+ ```
414
+
415
+ ### CSV Export
416
+
417
+ ```bash
418
+ flash export --csv
419
+ ```
420
+
421
+ Creates directory with individual CSV files per table.
422
+
423
+ ### SQLite Export
424
+
425
+ ```bash
426
+ flash export --sqlite
427
+ ```
428
+
429
+ Creates portable `.db` file.
430
+
431
+ ## 🎨 FlashORM Studio
432
+
433
+ Launch the visual database editor:
434
+
435
+ ```bash
436
+ flash studio
437
+ ```
438
+
439
+ Open http://localhost:5555 (or your custom port)
440
+
441
+ **Features:**
442
+
443
+ ### 1. Data Browser (`/`)
444
+
445
+ - View all tables in sidebar
446
+ - Click any table to view/edit data
447
+ - Double-click cells for inline editing
448
+ - Add/delete rows with intuitive modals
449
+ - Pagination (50 rows per page)
450
+ - Search across tables
451
+ - Foreign key hints
452
+
453
+ ### 2. SQL Editor (`/sql`)
454
+
455
+ - Execute custom SQL queries
456
+ - CodeMirror editor with syntax highlighting
457
+ - Press Ctrl+Enter to run queries
458
+ - Export results to CSV
459
+ - Resizable split-pane interface
460
+ - Query history
461
+
462
+ ### 3. Schema Visualization (`/schema`)
463
+
464
+ - Interactive database diagram
465
+ - React + ReactFlow rendering
466
+ - Automatic layout with Dagre algorithm
467
+ - Drag and drop tables
468
+ - Zoom and pan controls
469
+ - Foreign key relationship arrows
470
+ - MiniMap for navigation
471
+
472
+ ## 💻 Raw SQL Execution
473
+
474
+ Execute SQL files or inline queries:
475
+
476
+ ```bash
477
+ # Execute SQL file
478
+ flash raw script.sql
479
+
480
+ # Execute inline query
481
+ flash raw -q "SELECT * FROM users LIMIT 10"
482
+
483
+ # Auto-detection (file if exists, otherwise query)
484
+ flash raw "SELECT COUNT(*) FROM orders"
485
+ ```
486
+
487
+ **Features:**
488
+
489
+ - Beautiful table output for SELECT queries
490
+ - ✅ Multi-statement execution
491
+ - ✅ Transaction support
492
+ - ✅ Auto-detection of file vs query
493
+ - ✅ Formatted error messages
494
+
495
+ **Example Output:**
496
+
497
+ ```bash
498
+ $ flash raw -q "SELECT id, name, email FROM users LIMIT 3"
499
+
500
+ 🎯 Database: postgresql
501
+
502
+ ⚡ Executing query...
503
+ Query executed successfully
504
+ 📊 3 row(s) returned
505
+
506
+ ┌────┬────────────┬─────────────────────┐
507
+ id │ name │ email │
508
+ ├────┼────────────┼─────────────────────┤
509
+ 1 │ Alice │ alice@example.com │
510
+ │ 2 │ Bob │ bob@example.com │
511
+ │ 3 │ Charlie │ charlie@example.com │
512
+ └────┴────────────┴─────────────────────┘
513
+ ```
514
+
515
+ d
516
+
517
+ ## 📚 Examples
518
+
519
+ Check out complete examples:
520
+
521
+ - [Python Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/python)
522
+ - [TypeScript Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/ts)
523
+ - [Go Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/go)
524
+
525
+ ## 🐛 Troubleshooting
526
+
527
+ ### Bun Postinstall Blocked
528
+
529
+ ```bash
530
+ bun pm trust flashorm
531
+ ```
532
+
533
+ ### Binary Not Found
534
+
535
+ ```bash
536
+ npm install -g flashorm --force
537
+ ```
538
+
539
+ ### Database Connection Failed
540
+
541
+ Check your `DATABASE_URL` in `.env` file.
542
+
543
+ ### Studio Not Loading
544
+
545
+ Make sure port 5555 is not in use, or specify a different port:
546
+
547
+ ```bash
548
+ flash studio --port 3000
549
+ ```
550
+
551
+ ## 📖 Documentation
552
+
553
+ - [Full Documentation](https://github.com/Lumos-Labs-HQ/flash)
554
+ - [How It Works](https://github.com/Lumos-Labs-HQ/flash/blob/main/docs/HOW_IT_WORKS.md)
555
+ - [Technology Stack](https://github.com/Lumos-Labs-HQ/flash/blob/main/docs/TECHNOLOGY_STACK.md)
556
+ - [Contributing](https://github.com/Lumos-Labs-HQ/flash/blob/main/docs/CONTRIBUTING.md)
557
+
558
+ ## 🌟 Key Highlights
559
+
560
+ - **Visual Database Editor**: Manage your database visually with FlashORM Studio
561
+ - **Raw SQL Support**: Execute SQL files or queries directly from CLI
562
+ - **Type-Safe**: Full TypeScript support with generated types
563
+ - **Fast**: 2.5x-10x faster than popular ORMs
564
+ - **Multi-DB**: PostgreSQL, MySQL, and SQLite support
565
+ - **Zero Config**: Works out of the box with sensible defaults
566
+
567
+ ## 📄 License
568
+
569
+ MIT License - see [LICENSE](https://github.com/Lumos-Labs-HQ/flash/blob/main/LICENSE)
570
+
571
+ ---
@@ -1,3 +1,3 @@
1
1
  """Flash ORM - A powerful, database-agnostic ORM"""
2
2
 
3
- __version__ = "2.4.1-beta-dev"
3
+ __version__ = "2.4.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flashorm
3
- Version: 2.4.1b0.dev0
3
+ Version: 2.4.3
4
4
  Summary: A powerful, database-agnostic ORM with multi-database support and type-safe code generation
5
5
  Home-page: https://github.com/Lumos-Labs-HQ/flash
6
6
  Author: Rana718
@@ -74,7 +74,7 @@ This creates:
74
74
 
75
75
  ```
76
76
  your-project/
77
- ├── flash.config.json
77
+ ├── flash.toml
78
78
  ├── .env
79
79
  └── db/
80
80
  ├── schema/
@@ -233,7 +233,7 @@ flash studio
233
233
  flash studio --port 3000
234
234
 
235
235
  # Connect to any database directly
236
- flash studio --db "postgresql://user:pass@localhost:5432/mydb"
236
+ flash studio "postgresql://user:pass@localhost:5432/mydb"
237
237
 
238
238
  # Launch without opening browser
239
239
  flash studio --browser=false
@@ -347,27 +347,22 @@ flash <command> --help
347
347
 
348
348
  ## ⚙️ Configuration
349
349
 
350
- **flash.config.json**
350
+ **flash.toml**
351
351
 
352
- ```json
353
- {
354
- "version": "2",
355
- "schema_path": "db/schema/schema.sql",
356
- "queries": "db/queries/",
357
- "migrations_path": "db/migrations",
358
- "export_path": "db/export",
359
- "database": {
360
- "provider": "postgresql",
361
- "url_env": "DATABASE_URL"
362
- },
363
- "gen": {
364
-
365
- "python": {
366
- "enabled": true,
367
- "async": false
368
- }
369
- }
370
- }
352
+ ```toml
353
+ version = "2"
354
+ schema_path = "db/schema/schema.sql"
355
+ queries = "db/queries/"
356
+ migrations_path = "db/migrations"
357
+ export_path = "db/export"
358
+
359
+ [database]
360
+ provider = "postgresql"
361
+ url_env = "DATABASE_URL"
362
+
363
+ [gen.python]
364
+ enabled = true
365
+ async = false
371
366
  ```
372
367
 
373
368
  **Python Generation Options:**
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "flashorm"
7
- version = "2.4.1-beta-dev"
7
+ version = "2.4.3"
8
8
  description = "A powerful, database-agnostic ORM with multi-database support and type-safe code generation"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -4,7 +4,7 @@ import subprocess
4
4
  import sys
5
5
  import os
6
6
 
7
- VERSION = '2.4.1-beta-dev'
7
+ VERSION = '2.4.3'
8
8
 
9
9
  class PostInstallCommand(install):
10
10
  def run(self):
File without changes
File without changes
File without changes