pgsql

package
v0.0.0-...-ac9d817 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package pgsql implements gdb.Driver, which supports operations for database PostgreSQL.

Note: 1. It does not support Save/Replace features. 2. It does not support Insert Ignore features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() gdb.Driver

New create and returns a driver that implements gdb.Driver, which supports operations for PostgreSql.

Types

type Driver

type Driver struct {
	*gdb.Core
}

Driver is the driver for postgresql database.

func (*Driver) CheckLocalTypeForField

func (d *Driver) CheckLocalTypeForField(ctx context.Context, fieldType string, fieldValue interface{}) (gdb.LocalType, error)

CheckLocalTypeForField checks and returns corresponding local golang type for given db type.

func (*Driver) ConvertValueForLocal

func (d *Driver) ConvertValueForLocal(ctx context.Context, fieldType string, fieldValue interface{}) (interface{}, error)

ConvertValueForLocal converts value to local Golang type of value according field type name from database. The parameter `fieldType` is in lower case, like: `float(5,2)`, `unsigned double(5,2)`, `decimal(10,2)`, `char(45)`, `varchar(100)`, etc.

func (*Driver) DoExec

func (d *Driver) DoExec(ctx context.Context, link gdb.Link, sql string, args ...interface{}) (result sql.Result, err error)

DoExec commits the sql string and its arguments to underlying driver through given link object and returns the execution result.

func (*Driver) DoFilter

func (d *Driver) DoFilter(ctx context.Context, link gdb.Link, sql string, args []interface{}) (newSql string, newArgs []interface{}, err error)

DoFilter deals with the sql string before commits it to underlying sql driver.

func (*Driver) DoInsert

func (d *Driver) DoInsert(ctx context.Context, link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption) (result sql.Result, err error)

DoInsert inserts or updates data forF given table.

func (*Driver) GetChars

func (d *Driver) GetChars() (charLeft string, charRight string)

GetChars returns the security char for this type of database.

func (*Driver) New

func (d *Driver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error)

New creates and returns a database object for postgresql. It implements the interface of gdb.Driver for extra database driver installation.

func (*Driver) Open

func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error)

Open creates and returns an underlying sql.DB object for pgsql. https://pkg.go.dev/github.com/lib/pq

func (*Driver) TableFields

func (d *Driver) TableFields(ctx context.Context, table string, schema ...string) (fields map[string]*gdb.TableField, err error)

TableFields retrieves and returns the fields' information of specified table of current schema.

func (*Driver) Tables

func (d *Driver) Tables(ctx context.Context, schema ...string) (tables []string, err error)

Tables retrieves and returns the tables of current schema. It's mainly used in cli tool chain for automatically generating the models.

type Result

type Result struct {
	sql.Result
	// contains filtered or unexported fields
}

func (Result) LastInsertId

func (pgr Result) LastInsertId() (int64, error)

func (Result) RowsAffected

func (pgr Result) RowsAffected() (int64, error)

Jump to

Keyboard shortcuts

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