datasource

package
v0.0.0-...-158c053 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSource

type DataSource interface {
	Connect() safego.Option[error]
	Disconnect() safego.Option[error]
	Ping() safego.Option[error]
	Query(string, ...any) (*sql.Rows, safego.Option[error])
	Exec(string, ...any) safego.Option[error]
}

type ExternalDb

type ExternalDb struct {
	// contains filtered or unexported fields
}

ExternalDb is a wrapper for the sql.DB type.

func NewExternalDb

func NewExternalDb(connectionStr string) *ExternalDb

NewExternalDb returns a new ExternalDb instance.

func (*ExternalDb) Connect

func (self *ExternalDb) Connect() safego.Option[error]

Connect connects to the database.

func (*ExternalDb) Disconnect

func (self *ExternalDb) Disconnect() safego.Option[error]

Disconnect disconnects from the database.

func (*ExternalDb) Exec

func (self *ExternalDb) Exec(query string, args ...any) safego.Option[error]

Exec executes a query that returns a single row.

func (*ExternalDb) Ping

func (self *ExternalDb) Ping() safego.Option[error]

Ping pings the database.

func (*ExternalDb) Query

func (self *ExternalDb) Query(query string, args ...any) (*sql.Rows, safego.Option[error])

Query executes a query that returns rows.

type SqliteDb

type SqliteDb struct {
	// contains filtered or unexported fields
}

SqliteDb is a wrapper for the sql.DB type.

func NewSqliteDb

func NewSqliteDb(dbPath string) *SqliteDb

NewSqliteDb returns a new SqliteDb instance.

func (*SqliteDb) Connect

func (self *SqliteDb) Connect() safego.Option[error]

Connect connects to the database.

func (*SqliteDb) Disconnect

func (self *SqliteDb) Disconnect() safego.Option[error]

Disconnect disconnects from the database.

func (*SqliteDb) Exec

func (self *SqliteDb) Exec(query string, args ...any) safego.Option[error]

Exec executes a query that returns a single row.

func (*SqliteDb) Ping

func (self *SqliteDb) Ping() safego.Option[error]

Ping pings the database.

func (*SqliteDb) Query

func (self *SqliteDb) Query(query string, args ...any) (*sql.Rows, safego.Option[error])

Query executes a query that returns rows.

Jump to

Keyboard shortcuts

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