Package Exports
- dreeked
- dreeked/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dreeked) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Insomma CLI Tool
AI-powered CLI tool to generate ORM schemas from PostgreSQL and MySQL databases using advanced language models.
Features
- Multi-Database Support: Works with both PostgreSQL and MySQL databases
- Multi-ORM Support: Generate schemas for Prisma, TypeORM, Drizzle, and Zod
- Complete Metadata Extraction: Tables, columns, relationships, indexes, enums, and constraints
- AI-Powered Generation: Uses Meta's Llama 3.3 70B model via DeepInfra
- Auto-Detection: Automatically detects database type from connection string
- Flexible Output: Write to file or output to stdout
- Connection Testing: Verify database connectivity before processing
- Comprehensive CLI: Multiple commands for different use cases
Installation
Global Installation
npm install -g insommaRun with npx
npx insomma --helpRun with bunx
bunx insomma --helpSetup
Get DeepInfra API Key
- Sign up at DeepInfra
- Get your API key from the dashboard
- Set it as an environment variable or pass it as an option
Set Environment Variable (Recommended)
export DEEPINFRA_API_KEY="your-api-key-here"Usage
PostgreSQL Examples
Basic Schema Generation
insomma \
--connection "postgres://user:password@localhost:5432/mydb" \
--orm prisma \
--output schema.prismaGenerate TypeORM Entities
insomma \
--connection "postgres://user:pass@host:port/db" \
--orm typeorm \
--output entities.tsMySQL Examples
Basic Schema Generation
insomma \
--connection "mysql://user:password@localhost:3306/mydb" \
--orm prisma \
--output schema.prismaGenerate Drizzle Schema
insomma \
--connection "mysql://user:pass@host:port/db" \
--orm drizzle \
--output schema.tsUniversal Examples
Generate Zod Validation Schemas
insomma \
--connection "postgres://user:pass@host:port/db" \
--orm zod \
--output validations.tsOutput to Console
insomma \
--connection "mysql://user:pass@host:port/db" \
--orm prismaSpecify Database Type Explicitly
insomma \
--connection "some-custom-connection-string" \
--type mysql \
--orm prismaTest Database Connection
# Auto-detect database type
insomma test-connection \
--connection "postgres://user:pass@host:port/db"
# Specify database type
insomma test-connection \
--connection "mysql://user:pass@host:port/db" \
--type mysqlList Database Tables
# PostgreSQL
insomma list-tables \
--connection "postgres://user:pass@host:port/db"
# MySQL
insomma list-tables \
--connection "mysql://user:pass@host:port/db"Command Options
Main Command
-c, --connection <string>- Database connection string (required)-t, --type <string>- Database type (postgres, mysql, auto) [default: auto]-o, --orm <string>- Target ORM (prisma, typeorm, drizzle, zod) [default: prisma]-f, --output <string>- Output file path (optional)--api-key <string>- DeepInfra API key (optional if env var set)--verbose- Enable verbose logging
Test Connection Command
-c, --connection <string>- Database connection string (required)-t, --type <string>- Database type (postgres, mysql, auto) [default: auto]
List Tables Command
-c, --connection <string>- Database connection string (required)-t, --type <string>- Database type (postgres, mysql, auto) [default: auto]
Connection String Formats
PostgreSQL
postgres://username:password@hostname:port/database
postgresql://username:password@hostname:port/databaseExamples:
# Local database
postgres://postgres:password@localhost:5432/myapp
# Remote database
postgres://user:pass@db.example.com:5432/production
# With SSL
postgres://user:pass@host:5432/db?sslmode=requireMySQL
mysql://username:password@hostname:port/databaseExamples:
# Local database
mysql://root:password@localhost:3306/myapp
# Remote database
mysql://user:pass@db.example.com:3306/production
# With SSL
mysql://user:pass@host:3306/db?ssl=trueDatabase Type Detection
The tool automatically detects the database type from the connection string:
- PostgreSQL: Detected by
postgres://,postgresql://prefixes or port:5432 - MySQL: Detected by
mysql://prefix or port:3306 - Manual Override: Use
--typeoption to specify explicitly
Supported ORMs
Prisma
Generates complete Prisma schema with:
- Generator and datasource blocks (PostgreSQL/MySQL specific)
- Proper data type mappings for each database
- Relationships with @relation
- Constraints and indexes
- Database-specific features
TypeORM
Generates TypeScript entity classes with:
- Proper decorators (@Entity, @Column, etc.)
- Database-specific type mappings
- Relationship definitions
- Column constraints
- Auto-increment handling
Drizzle
Generates Drizzle schema with:
- Database-specific imports (pg-core/mysql-core)
- Table definitions using pgTable/mysqlTable
- Proper column types for each database
- Foreign key relationships
- Constraints and indexes
Zod
Generates validation schemas with:
- Type-safe validations
- Database-appropriate Zod types
- Optional/required field handling
- Custom validations
- Database-specific field handling
Examples by Database
E-commerce PostgreSQL to Prisma
insomma \
--connection "postgres://admin:secret@localhost:5432/ecommerce" \
--orm prisma \
--output prisma/schema.prisma \
--verboseBlog MySQL to TypeORM
insomma \
--connection "mysql://blogger:pass123@blog-db:3306/blog" \
--orm typeorm \
--output src/entities/index.tsAnalytics PostgreSQL to Drizzle
insomma \
--connection "postgres://analyst:data@analytics.internal:5432/metrics" \
--orm drizzle \
--output lib/schema.tsCRM MySQL to Zod
insomma \
--connection "mysql://crm:secure@crm.company.com:3306/customer_data" \
--orm zod \
--output lib/validations.tsMetadata Extraction
The tool extracts comprehensive database metadata including:
PostgreSQL
- Tables: Names, schemas, comments
- Columns: Data types, constraints, defaults, comments
- Relationships: Foreign keys with cascade rules
- Indexes: Custom indexes (excluding primary keys)
- Enums: PostgreSQL enum types and values
- Constraints: Primary keys, unique constraints, check constraints
MySQL
- Tables: Names, schemas, comments
- Columns: Data types, constraints, defaults, comments, auto-increment
- Relationships: Foreign keys with cascade rules
- Indexes: Custom indexes (excluding primary keys)
- Enums: ENUM and SET column types
- Constraints: Primary keys, unique constraints
Database-Specific Features
PostgreSQL Features
- Full schema support
- Custom enum types
- Advanced constraint types
- UUID and serial types
- JSONB support
MySQL Features
- Auto-increment columns
- ENUM and SET types
- Unsigned integer types
- MySQL-specific data types
- Storage engine considerations
Error Handling
The tool provides clear error messages for:
- Invalid connection strings
- Unsupported database types
- Network connectivity issues
- API authentication problems
- Unsupported database features
- File system permissions
Troubleshooting
Connection Issues
# Test your connection first
insomma test-connection --connection "your-connection-string"
# Specify database type if auto-detection fails
insomma test-connection --connection "your-connection-string" --type mysqlDatabase Type Detection Issues
# Force database type
insomma --type postgres --connection "..." --orm prisma
insomma --type mysql --connection "..." --orm prismaAPI Key Issues
# Verify your API key is set
echo $DEEPINFRA_API_KEY
# Or pass it directly
insomma --api-key "your-key" --connection "..." --orm prismaVerbose Logging
# Enable verbose output for debugging
insomma --verbose --connection "..." --orm prismaRequirements
- Node.js 16 or higher
- PostgreSQL or MySQL database access
- DeepInfra API key
- Internet connection for AI generation
Supported Database Versions
PostgreSQL
- PostgreSQL 10+
- All major cloud providers (AWS RDS, Google Cloud SQL, Azure Database)
MySQL
- MySQL 5.7+
- MySQL 8.0+
- MariaDB 10.3+
- All major cloud providers (AWS RDS, Google Cloud SQL, Azure Database)
License
MIT License - see LICENSE file for details.