Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GoDB-Orm

GoDB-Orm Logo

Database Model Generator for Go/GORM

Generate Go ORM structs from your database tables with a beautiful GUI or CLI

Go Vue 3 Wails Platform License


✨ Features

  • πŸ–₯️ Modern GUI - Beautiful desktop application built with Wails v2 + Vue 3
  • πŸŒ“ Dark/Light Theme - Toggle between dark and light themes
  • 🐬 MySQL Support - Full MySQL/MariaDB database introspection
  • 🐘 PostgreSQL Support - Full PostgreSQL with schema selection
  • 🏷️ GORM Tags - Auto-generated GORM struct tags with type mapping
  • πŸ“ Smart Type Mapping - Intelligent database-to-Go type conversion
  • πŸ’Ύ Export Models - Save individual or all models to files
  • πŸ”§ CLI Mode - Command-line interface for automation
  • πŸ’‘ Live Preview - Real-time code preview with syntax highlighting

πŸ“Έ Screenshots

Dark Theme

Dark Theme

Light Theme

Light Theme

πŸš€ Installation

Prerequisites

  • Go 1.23 or higher
  • Node.js 18 or higher
  • Wails CLI

Build from Source

# Clone the repository
git clone https://github.com/rowjak/godb-orm.git
cd godb-orm

# Install Wails CLI (if not installed)
go install github.com/wailsapp/wails/v2/cmd/wails@latest

# Build the application
wails build

# The binary will be in build/bin/

Development Mode

# Run in development mode with hot-reload
wails dev

πŸ“– Usage

GUI Mode

  1. Launch the application
  2. Enter your database connection details:
    • Host: Database host (e.g., localhost)
    • Port: Database port (MySQL: 3306, PostgreSQL: 5432)
    • User: Database username
    • Password: Database password
    • Database: Database name
    • Driver: Select MySQL or PostgreSQL
  3. Click Connect
  4. For PostgreSQL, select the desired Schema
  5. Browse and select tables from the left panel
  6. View the generated Go struct in the code preview panel
  7. Click Copy to copy to clipboard or Save to export to file

CLI Mode

# Generate models for all tables
godb-orm --host localhost --port 3306 --user root --db mydb --driver mysql

# Generate model for a specific table
godb-orm -H localhost -P 3306 -u root -d mydb --driver mysql --table users

# PostgreSQL with schema
godb-orm --host localhost --port 5432 --user postgres --db mydb --driver postgres --schema public

Configuration

The application saves your connection settings to ~/.godb-orm/config.yaml for convenience.

πŸ—οΈ Project Structure

godb-orm/
β”œβ”€β”€ app.go                 # Main Wails application & bridge
β”œβ”€β”€ main.go                # Entry point
β”œβ”€β”€ wails.json             # Wails configuration
β”œβ”€β”€ cmd/
β”‚   └── root.go            # CLI commands (Cobra)
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ config/            # Configuration management
β”‚   β”œβ”€β”€ database/          # Database introspection
β”‚   β”‚   β”œβ”€β”€ models.go      # Data models
β”‚   β”‚   β”œβ”€β”€ connection.go  # Connection factory
β”‚   β”‚   β”œβ”€β”€ mysql_introspector.go
β”‚   β”‚   └── postgres_introspector.go
β”‚   └── generator/         # Code generation
β”‚       β”œβ”€β”€ generator.go   # Main generator
β”‚       β”œβ”€β”€ tagbuilder.go  # GORM tag builder
β”‚       β”œβ”€β”€ typemapper.go  # DB-to-Go type mapping
β”‚       └── template.go    # Go struct template
β”œβ”€β”€ frontend/              # Vue 3 frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.vue        # Main component
β”‚   β”‚   └── style.css      # Global styles & themes
β”‚   └── public/
β”‚       └── appicon.webp   # App icon
└── build/
    └── appicon.png        # Build assets

πŸ”§ Supported Database Types

MySQL/MariaDB

MySQL Type Go Type
INT, INTEGER int32
BIGINT int64
SMALLINT int16
TINYINT int8
TINYINT(1) bool
FLOAT float32
DOUBLE, DECIMAL float64
VARCHAR, TEXT string
DATETIME, TIMESTAMP time.Time
DATE time.Time
JSON datatypes.JSON
BLOB, BINARY []byte
ENUM string

PostgreSQL

PostgreSQL Type Go Type
INTEGER, INT4 int32
BIGINT, INT8 int64
SMALLINT, INT2 int16
BOOLEAN bool
REAL, FLOAT4 float32
DOUBLE PRECISION, FLOAT8 float64
NUMERIC, DECIMAL float64
VARCHAR, TEXT string
TIMESTAMP, TIMESTAMPTZ time.Time
DATE time.Time
UUID uuid.UUID
JSON, JSONB datatypes.JSON
BYTEA []byte
SERIAL, BIGSERIAL int32, int64

πŸ“„ Example Output

package models

import (
	"time"
)

// User represents the users table
type User struct {
	ID        int64     `gorm:"primaryKey;autoIncrement;column:id;type:bigint" json:"id"`
	Name      string    `gorm:"column:name;type:varchar(255);not null" json:"name"`
	Email     string    `gorm:"column:email;type:varchar(255);not null" json:"email"`
	Password  string    `gorm:"column:password;type:varchar(255);not null" json:"password"`
	CreatedAt time.Time `gorm:"column:created_at;type:timestamp" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp" json:"updated_at"`
}

// TableName returns the table name for GORM
func (User) TableName() string {
	return "users"
}

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ‘€ Author

Abdur Rozaq

About

Database Model Generator for Go/GORM. Generate Go ORM structs from your database tables with a beautiful GUI or CLI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages