gf/contrib/drivers
John Guo 455830b842
Some checks failed
GoFrame Main CI / code-test (1.20, 386) (push) Has been cancelled
GoFrame Main CI / code-test (1.20, amd64) (push) Has been cancelled
GoFrame Main CI / code-test (1.21, 386) (push) Has been cancelled
GoFrame Main CI / code-test (1.21, amd64) (push) Has been cancelled
GoFrame Main CI / code-test (1.22, 386) (push) Has been cancelled
GoFrame Main CI / code-test (1.22, amd64) (push) Has been cancelled
GoFrame Main CI / code-test (1.23, 386) (push) Has been cancelled
GoFrame Main CI / code-test (1.23, amd64) (push) Has been cancelled
GoFrame Sub CI / code-test (1.20, 386) (push) Has been cancelled
GoFrame Sub CI / code-test (1.20, amd64) (push) Has been cancelled
GoFrame Sub CI / code-test (1.21, 386) (push) Has been cancelled
GoFrame Sub CI / code-test (1.21, amd64) (push) Has been cancelled
GoFrame Sub CI / code-test (1.22, 386) (push) Has been cancelled
GoFrame Sub CI / code-test (1.22, amd64) (push) Has been cancelled
GoFrame Sub CI / code-test (1.23, 386) (push) Has been cancelled
GoFrame Sub CI / code-test (1.23, amd64) (push) Has been cancelled
Sync to Gitee / Run (push) Has been cancelled
GolangCI-Lint / golangci-lint (1.20) (push) Has been cancelled
GolangCI-Lint / golangci-lint (1.21.4) (push) Has been cancelled
GolangCI-Lint / golangci-lint (1.22) (push) Has been cancelled
GolangCI-Lint / golangci-lint (1.23) (push) Has been cancelled
Sonarcloud Scan / Scorecards analysis (push) Has been cancelled
Deploy to GitHub Pages / Deploy to GitHub Pages (push) Has been cancelled
test(database/gdb): add more unit testing cases for Raw feature (#3962)
2024-11-23 18:35:02 +08:00
..
clickhouse feat: new version v2.8.1 (#3950) 2024-11-21 20:51:46 +08:00
dm feat: new version v2.8.1 (#3950) 2024-11-21 20:51:46 +08:00
mssql feat: new version v2.8.1 (#3950) 2024-11-21 20:51:46 +08:00
mysql test(database/gdb): add more unit testing cases for Raw feature (#3962) 2024-11-23 18:35:02 +08:00
oracle feat: new version v2.8.1 (#3950) 2024-11-21 20:51:46 +08:00
pgsql feat: new version v2.8.1 (#3950) 2024-11-21 20:51:46 +08:00
sqlite feat: new version v2.8.1 (#3950) 2024-11-21 20:51:46 +08:00
sqlitecgo feat: new version v2.8.1 (#3950) 2024-11-21 20:51:46 +08:00
README.MD contrib/drivers: add README.zh_CN.MD (#3604) 2024-05-27 21:02:02 +08:00
README.zh_CN.MD contrib/drivers: add README.zh_CN.MD (#3604) 2024-05-27 21:02:02 +08:00

简体中文

Database drivers

Powerful database drivers for package gdb.

Installation

Let's take mysql for example.

go get -u github.com/gogf/gf/contrib/drivers/mysql/v2
# Easy to copy
go get -u github.com/gogf/gf/contrib/drivers/clickhouse/v2
go get -u github.com/gogf/gf/contrib/drivers/dm/v2
go get -u github.com/gogf/gf/contrib/drivers/mssql/v2
go get -u github.com/gogf/gf/contrib/drivers/oracle/v2
go get -u github.com/gogf/gf/contrib/drivers/pgsql/v2
go get -u github.com/gogf/gf/contrib/drivers/sqlite/v2
go get -u github.com/gogf/gf/contrib/drivers/sqlitecgo/v2

Choose and import the driver to your project:

import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"

Commonly imported at top of main.go:

package main

import (
	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"

	// Other imported packages.
)

func main() {
	// Main logics.
}

Supported Drivers

MySQL/MariaDB/TiDB

import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"

SQLite

import _ "github.com/gogf/gf/contrib/drivers/sqlite/v2"

cgo version

When the target is a 32-bit Windows system, the cgo version needs to be used.

import _ "github.com/gogf/gf/contrib/drivers/sqlitecgo/v2"

PostgreSQL

import _ "github.com/gogf/gf/contrib/drivers/pgsql/v2"

Note:

  • It does not support Replace features.

SQL Server

import _ "github.com/gogf/gf/contrib/drivers/mssql/v2"

Note:

  • It does not support Replace features.
  • It does not support LastInsertId.
  • It supports server version >= SQL Server2005
  • It ONLY supports datetime2 and datetimeoffset types for auto handling created_at/updated_at/deleted_at columns, because datetime type does not support microseconds precision when column value is passed as string.

Oracle

import _ "github.com/gogf/gf/contrib/drivers/oracle/v2"

Note:

  • It does not support Replace features.
  • It does not support LastInsertId.

ClickHouse

import _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"

Note:

  • It does not support InsertIgnore/InsertGetId features.
  • It does not support Save/Replace features.
  • It does not support Transaction feature.
  • It does not support RowsAffected feature.

DM

import _ "github.com/gogf/gf/contrib/drivers/dm/v2"

Note:

  • It does not support Replace features.

Custom Drivers

It's quick and easy, please refer to current driver source. It's quite appreciated if any PR for new drivers support into current repo.