gf/contrib/drivers/README.MD

94 lines
2.0 KiB
Plaintext
Raw Normal View History

2022-01-24 14:47:22 +08:00
# drivers
2022-05-13 21:54:24 +08:00
Powerful database drivers for package gdb.
# Installation
2022-05-13 21:54:24 +08:00
Let's take `mysql` for example.
```
2022-05-13 21:54:24 +08:00
go get -u github.com/gogf/gf/contrib/drivers/mysql/v2
```
Choose and import the driver to your project:
```
2022-05-13 21:54:24 +08:00
import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
```
Commonly imported at top of `main.go`:
```go
package main
import (
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
// Other imported packages.
)
func main() {
// Main logics.
}
```
# Supported Drivers
2022-04-12 21:31:51 +08:00
## MySQL/MariaDB/TiDB
```
import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
```
## SQLite
```
import _ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
```
Note:
2022-06-06 19:57:53 +08:00
- It does not support `Save` features.
## PostgreSQL
```
import _ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
```
Note:
- It does not support `Save/Replace` features.
- It does not support `LastInsertId`.
## SQL Server
```
import _ "github.com/gogf/gf/contrib/drivers/mssql/v2"
```
Note:
- It does not support `Save/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 `Save/Replace` features.
- It does not support `LastInsertId`.
2022-04-12 21:31:51 +08:00
## 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.
2022-04-12 21:31:51 +08:00
2022-09-26 22:11:13 +08:00
## 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.