db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(dbType, host string, port int, user, password, dbName string) error

Connect 连接到数据库

func Disconnect

func Disconnect() error

Disconnect 断开当前连接

Types

type Connection

type Connection interface {
	Connect() error
	Disconnect() error
	Query(query string) ([]map[string]interface{}, error)
	QueryWithParams(query string, args ...interface{}) ([]map[string]interface{}, error)
	Execute(query string) (int64, error)
	ExecuteWithParams(query string, args ...interface{}) (int64, error)
	GetTables() ([]string, error)
	DescribeTable(tableName string) ([]map[string]interface{}, error)
	GetTableColumns(tableName string) ([]string, error)
}

Connection 数据库连接接口

func GetCurrentConnection

func GetCurrentConnection() Connection

GetCurrentConnection 获取当前连接

func NewOracleConnection

func NewOracleConnection(config *DbConfig) (Connection, error)

NewOracleConnection 创建Oracle数据库连接

type DamengConnection

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

DamengConnection 达梦数据库连接

func NewDamengConnection

func NewDamengConnection(config *DbConfig) (*DamengConnection, error)

NewDamengConnection 创建达梦数据库连接

func (*DamengConnection) Connect

func (d *DamengConnection) Connect() error

Connect 连接到达梦数据库

func (*DamengConnection) DescribeTable

func (d *DamengConnection) DescribeTable(tableName string) ([]map[string]interface{}, error)

DescribeTable 获取表结构

func (*DamengConnection) Disconnect

func (d *DamengConnection) Disconnect() error

Disconnect 断开连接

func (*DamengConnection) Execute

func (d *DamengConnection) Execute(query string) (int64, error)

Execute 执行更新/插入/删除语句

func (*DamengConnection) ExecuteWithParams

func (d *DamengConnection) ExecuteWithParams(query string, args ...interface{}) (int64, error)

ExecuteWithParams 执行带参数的更新/插入/删除语句

func (*DamengConnection) GetTableColumns

func (d *DamengConnection) GetTableColumns(tableName string) ([]string, error)

GetTableColumns 获取表字段列表,按字段在表中的顺序排序

func (*DamengConnection) GetTables

func (d *DamengConnection) GetTables() ([]string, error)

GetTables 获取所有表

func (*DamengConnection) Query

func (d *DamengConnection) Query(query string) ([]map[string]interface{}, error)

Query 执行查询语句

func (*DamengConnection) QueryWithParams

func (d *DamengConnection) QueryWithParams(query string, args ...interface{}) ([]map[string]interface{}, error)

QueryWithParams 执行带参数的查询语句

type DbConfig

type DbConfig struct {
	Type     string
	Host     string
	Port     int
	User     string
	Password string
	DbName   string
}

DbConfig 数据库配置

func GetCurrentConfig

func GetCurrentConfig() *DbConfig

GetCurrentConfig 获取当前数据库配置

type MSSQLConnection

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

MSSQLConnection MSSQL数据库连接

func NewMSSQLConnection

func NewMSSQLConnection(config *DbConfig) (*MSSQLConnection, error)

NewMSSQLConnection 创建MSSQL数据库连接

func (*MSSQLConnection) Connect

func (m *MSSQLConnection) Connect() error

Connect 连接到MSSQL数据库

func (*MSSQLConnection) DescribeTable

func (m *MSSQLConnection) DescribeTable(tableName string) ([]map[string]interface{}, error)

DescribeTable 获取表结构

func (*MSSQLConnection) Disconnect

func (m *MSSQLConnection) Disconnect() error

Disconnect 断开连接

func (*MSSQLConnection) Execute

func (m *MSSQLConnection) Execute(query string) (int64, error)

Execute 执行更新/插入/删除语句

func (*MSSQLConnection) ExecuteWithParams

func (m *MSSQLConnection) ExecuteWithParams(query string, args ...interface{}) (int64, error)

ExecuteWithParams 执行带参数的更新/插入/删除语句

func (*MSSQLConnection) GetTableColumns

func (m *MSSQLConnection) GetTableColumns(tableName string) ([]string, error)

GetTableColumns 获取表列名

func (*MSSQLConnection) GetTables

func (m *MSSQLConnection) GetTables() ([]string, error)

GetTables 获取所有表

func (*MSSQLConnection) Query

func (m *MSSQLConnection) Query(query string) ([]map[string]interface{}, error)

Query 执行查询语句

func (*MSSQLConnection) QueryWithParams

func (m *MSSQLConnection) QueryWithParams(query string, args ...interface{}) ([]map[string]interface{}, error)

QueryWithParams 执行带参数的查询语句

type MySQLConnection

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

MySQLConnection MySQL数据库连接

func NewMySQLConnection

func NewMySQLConnection(config *DbConfig) (*MySQLConnection, error)

NewMySQLConnection 创建MySQL数据库连接

func (*MySQLConnection) Connect

func (m *MySQLConnection) Connect() error

Connect 连接到MySQL数据库

func (*MySQLConnection) DescribeTable

func (m *MySQLConnection) DescribeTable(tableName string) ([]map[string]interface{}, error)

DescribeTable 获取表结构

func (*MySQLConnection) Disconnect

func (m *MySQLConnection) Disconnect() error

Disconnect 断开连接

func (*MySQLConnection) Execute

func (m *MySQLConnection) Execute(query string) (int64, error)

Execute 执行更新/插入/删除语句

func (*MySQLConnection) ExecuteWithParams

func (m *MySQLConnection) ExecuteWithParams(query string, args ...interface{}) (int64, error)

ExecuteWithParams 执行带参数的更新/插入/删除语句

func (*MySQLConnection) GetTableColumns

func (m *MySQLConnection) GetTableColumns(tableName string) ([]string, error)

GetTableColumns 获取表字段列表,按字段在表中的顺序排序

func (*MySQLConnection) GetTables

func (m *MySQLConnection) GetTables() ([]string, error)

GetTables 获取所有表

func (*MySQLConnection) Query

func (m *MySQLConnection) Query(query string) ([]map[string]interface{}, error)

Query 执行查询语句

func (*MySQLConnection) QueryWithParams

func (m *MySQLConnection) QueryWithParams(query string, args ...interface{}) ([]map[string]interface{}, error)

QueryWithParams 执行带参数的查询语句

type OracleConnection

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

OracleConnection Oracle数据库连接

func (*OracleConnection) Connect

func (o *OracleConnection) Connect() error

Connect 连接到Oracle数据库

func (*OracleConnection) DescribeTable

func (o *OracleConnection) DescribeTable(tableName string) ([]map[string]interface{}, error)

DescribeTable 获取表结构

func (*OracleConnection) Disconnect

func (o *OracleConnection) Disconnect() error

Disconnect 断开连接

func (*OracleConnection) Execute

func (o *OracleConnection) Execute(query string) (int64, error)

Execute 执行更新/插入/删除语句

func (*OracleConnection) ExecuteWithParams

func (o *OracleConnection) ExecuteWithParams(query string, args ...interface{}) (int64, error)

ExecuteWithParams 执行带参数的更新/插入/删除语句

func (*OracleConnection) GetTableColumns

func (o *OracleConnection) GetTableColumns(tableName string) ([]string, error)

GetTableColumns 获取表列名

func (*OracleConnection) GetTables

func (o *OracleConnection) GetTables() ([]string, error)

GetTables 获取所有表

func (*OracleConnection) Query

func (o *OracleConnection) Query(query string) ([]map[string]interface{}, error)

Query 执行查询语句

func (*OracleConnection) QueryWithParams

func (o *OracleConnection) QueryWithParams(query string, args ...interface{}) ([]map[string]interface{}, error)

QueryWithParams 执行带参数的查询语句

type PostgresConnection

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

PostgresConnection PostgreSQL数据库连接

func NewPostgresConnection

func NewPostgresConnection(config *DbConfig) (*PostgresConnection, error)

NewPostgresConnection 创建PostgreSQL数据库连接

func (*PostgresConnection) Connect

func (p *PostgresConnection) Connect() error

Connect 连接到PostgreSQL数据库

func (*PostgresConnection) DescribeTable

func (p *PostgresConnection) DescribeTable(tableName string) ([]map[string]interface{}, error)

DescribeTable 获取表结构

func (*PostgresConnection) Disconnect

func (p *PostgresConnection) Disconnect() error

Disconnect 断开连接

func (*PostgresConnection) Execute

func (p *PostgresConnection) Execute(query string) (int64, error)

Execute 执行更新/插入/删除语句

func (*PostgresConnection) ExecuteWithParams

func (p *PostgresConnection) ExecuteWithParams(query string, args ...interface{}) (int64, error)

ExecuteWithParams 执行带参数的更新/插入/删除语句

func (*PostgresConnection) GetTableColumns

func (p *PostgresConnection) GetTableColumns(tableName string) ([]string, error)

GetTableColumns 获取表字段列表,按字段在表中的顺序排序

func (*PostgresConnection) GetTables

func (p *PostgresConnection) GetTables() ([]string, error)

GetTables 获取所有表

func (*PostgresConnection) Query

func (p *PostgresConnection) Query(query string) ([]map[string]interface{}, error)

Query 执行查询语句

func (*PostgresConnection) QueryWithParams

func (p *PostgresConnection) QueryWithParams(query string, args ...interface{}) ([]map[string]interface{}, error)

QueryWithParams 执行带参数的查询语句

Jump to

Keyboard shortcuts

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