gf/contrib/drivers
2024-04-16 19:31:06 +08:00
..
clickhouse feat: add metrics option and prometheus handler wraps (#3445) 2024-04-07 09:57:13 +08:00
dm emhace: unit testing cases update for package cmd/gf and contrib/drivers (#3453) 2024-04-10 20:55:09 +08:00
mssql emhace: unit testing cases update for package cmd/gf and contrib/drivers (#3453) 2024-04-10 20:55:09 +08:00
mysql fix: #3238 first column might be overwritten in interal context data in multiple goroutines querying (#3476) 2024-04-16 19:31:06 +08:00
oracle emhace: unit testing cases update for package cmd/gf and contrib/drivers (#3453) 2024-04-10 20:55:09 +08:00
pgsql feat: add metrics option and prometheus handler wraps (#3445) 2024-04-07 09:57:13 +08:00
sqlite feat: add metrics option and prometheus handler wraps (#3445) 2024-04-07 09:57:13 +08:00
sqlitecgo fix: sqlitecgo to support 32-bit architecture (#3480) 2024-04-15 10:03:49 +08:00
README.MD fix: sqlitecgo to support 32-bit architecture (#3480) 2024-04-15 10:03:49 +08:00

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 for 32-bit windows

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.