tablecli

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

tablecli

Relational(Table) database client quick connecter

Documentation

Index

Constants

View Source
const (
	DefaultCreateBatchSize = 1000
)

Variables

This section is empty.

Functions

func CreateDatabaseIfNotExists

func CreateDatabaseIfNotExists(driverName, dataSourceName, databaseName string,
	ops ...Option) error

CreateDatabaseIfNotExists If database not exists, then create it.

func GormComment

func GormComment(description string) string

GormComment get table comment for the description.

func NewConnection

func NewConnection(config *Config, ops ...Option) (*gorm.DB, error)

NewConnection create a new gorm db instance with the given options.

func NewDataSourceName

func NewDataSourceName(host, username, password, database string,
	ops ...Option) string

NewDataSourceName initialize database of the data source name. If database parameter is empty, will not choose database, such as only open database connection.

func NewDataSourceNameForConfig

func NewDataSourceNameForConfig(config *Config, ops ...Option) string

NewDataSourceNameForConfig Get data source name for given options.

func NewDataSourceNameForNoSelectDatabase

func NewDataSourceNameForNoSelectDatabase(host, username, password string,
	ops ...Option) string

Types

type Config

type Config struct {
	Host                  string
	Username              string
	Password              string
	Database              string
	MaxIdleConnections    int
	MaxOpenConnections    int
	MaxConnectionLifeTime time.Duration
}

Config defines config for database.

type DriverName

type DriverName string
const (
	DriverNameOfMySQL  DriverName = "mysql"
	DriverNameOfSQLite DriverName = "sqlite"
)

func (DriverName) String

func (d DriverName) String() string

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithCharset

func WithCharset(charset string) Option

func WithDisableForeignKeyConstraintWhenMigrating added in v0.1.3

func WithDisableForeignKeyConstraintWhenMigrating(disable bool) Option

func WithDriverName added in v0.1.4

func WithDriverName(driverName DriverName) Option

func WithLocation

func WithLocation(loc string) Option

func WithLogLevel added in v0.1.3

func WithLogLevel(logLevel int) Option

func WithLogger added in v0.1.3

func WithLogger(logger logger.Interface) Option

func WithNamingStrategy added in v0.1.3

func WithNamingStrategy(strategy schema.NamingStrategy) Option

func WithParseTime

func WithParseTime(parseTime bool) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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