sqlorm

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 5 Imported by: 1

README

SQL → ORM Schema Importer

This tool imports the SQL database schemas and generates ORM code for use in Kratos microservices, supporting both ent and gorm ORMs.

HOW TO INSTALL

go install github.com/tx7do/kratos-cli/sql-orm/cmd/sql2orm@latest

HOW TO USE

sql2orm is a tool to generate ORM code from SQL database schemas.

Usage:
  sql2orm [flags]

Flags:
  -d, --dao-path string          output path for DAO code (for gorm) (default "./daos/")
  -v, --drv string               Database driver name to use (mysql, postgres, sqlite...) (default "mysql")
  -n, --dsn string               Data source name (connection information), for example:
                                 "mysql://user:pass@tcp(localhost:3306)/dbname"
                                 "postgres://user:pass@host:port/dbname"
  -e, --exclude-tables strings   comma-separated list of tables to exclude
  -h, --help                     help for sql2orm
  -o, --orm string               ORM type to use (ent, gorm) (default "ent")
  -s, --schema-path string       output path for schema (default "./ent/schema/")
  -t, --tables strings           comma-separated list of tables to inspect (all if empty)

EXAMPLES

for ent ORM:

sql2orm \
  --orm "ent" \
  --dsn "postgres://postgres:pass@localhost:5432/test?sslmode=disable" \
  --schema-path "./ent/schema"

for gorm ORM:

sql2orm \
  --orm "gorm" \
  --drv "postgres" \
  --dsn "postgres://postgres:pass@localhost:5432/test?sslmode=disable" \
  --schema-path "./daos/models" \
  --dao-path "./daos/"

ACKNOWLEDGEMENT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Importer

func Importer(
	ctx context.Context,
	orm string,
	drv, dsn,
	schemaPath, daoPath *string,
	includeTables, excludeTables []string,
) error

Types

type OrmType added in v0.0.2

type OrmType string
const (
	OrmTypeEnt  OrmType = "ent"
	OrmTypeGorm OrmType = "gorm"
)

Directories

Path Synopsis
cmd
sql2orm command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL