orm

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package orm provides GORM dialector dispatch for 8 database drivers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dialector

func Dialector(driver, dsn string) (gorm.Dialector, error)

Dialector returns a gorm.Dialector for the given driver name and DSN. The 8 supported names are: mysql, postgres, tidb, mariadb, gaussdb, mssql, oracle, sqlite. TiDB and MariaDB wire-compatibly use the mysql dialector; GaussDB uses the postgres dialector.

func Open

func Open(cfg DialectorSource, opts ...gorm.Option) (*gorm.DB, error)

Open opens a *gorm.DB from a DialectorSource. Accepting a narrow interface keeps callers like dbsql.Open (which needs the full DBConfig) decoupled from callers like dbsql.OpenCluster (which only needs driver+DSN).

func SupportedDrivers

func SupportedDrivers() []string

SupportedDrivers returns the list of supported driver names.

Types

type DialectorSource

type DialectorSource interface {
	DriverName() string
	DSN() string
}

DialectorSource is the minimal interface Open needs from a config: the driver name and the connection string. Every *XxxConfig in the config package already has both methods, so accepting a narrower interface here lets callers that don't need Validate/GetPool/GetTracing (e.g. a read/write-split cluster source) avoid implementing empty stubs.

Jump to

Keyboard shortcuts

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