2022-01-24 14:47:22 +08:00
|
|
|
# drivers
|
2022-05-13 21:54:24 +08:00
|
|
|
Powerful database drivers for package gdb.
|
2022-01-24 14:41:23 +08:00
|
|
|
|
|
|
|
# Installation
|
2022-05-13 21:54:24 +08:00
|
|
|
Let's take `mysql` for example.
|
2022-01-24 14:41:23 +08:00
|
|
|
```
|
2022-05-13 21:54:24 +08:00
|
|
|
go get -u github.com/gogf/gf/contrib/drivers/mysql/v2
|
2022-01-24 14:41:23 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
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.
|
|
|
|
}
|
2022-01-24 14:41:23 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
# Supported Drivers
|
|
|
|
|
2022-04-12 21:31:51 +08:00
|
|
|
## MySQL/MariaDB/TiDB
|
2022-01-24 14:41:23 +08:00
|
|
|
|
2022-04-15 14:47:02 +08:00
|
|
|
```
|
|
|
|
import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
|
|
|
```
|
2022-01-24 14:41:23 +08:00
|
|
|
|
|
|
|
## SQLite
|
|
|
|
```
|
2022-01-27 12:04:46 +08:00
|
|
|
import _ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
|
2022-01-24 14:41:23 +08:00
|
|
|
```
|
|
|
|
Note:
|
2022-06-06 19:57:53 +08:00
|
|
|
- It does not support `Save` features.
|
2022-01-24 14:41:23 +08:00
|
|
|
|
|
|
|
## PostgreSQL
|
|
|
|
```
|
2022-01-27 12:04:46 +08:00
|
|
|
import _ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
|
2022-01-24 14:41:23 +08:00
|
|
|
```
|
|
|
|
Note:
|
|
|
|
- It does not support `Save/Replace` features.
|
|
|
|
- It does not support `LastInsertId`.
|
|
|
|
|
|
|
|
## SQL Server
|
|
|
|
```
|
2022-01-27 12:04:46 +08:00
|
|
|
import _ "github.com/gogf/gf/contrib/drivers/mssql/v2"
|
2022-01-24 14:41:23 +08:00
|
|
|
```
|
|
|
|
Note:
|
|
|
|
- It does not support `Save/Replace` features.
|
|
|
|
- It does not support `LastInsertId`.
|
|
|
|
- It supports server version >= `SQL Server2005`
|
|
|
|
|
|
|
|
## Oracle
|
|
|
|
```
|
2022-01-27 12:04:46 +08:00
|
|
|
import _ "github.com/gogf/gf/contrib/drivers/oracle/v2"
|
2022-01-24 14:41:23 +08:00
|
|
|
```
|
|
|
|
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.
|
2022-05-23 21:21:59 +08:00
|
|
|
- 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.
|
2022-10-09 21:23:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 14:41:23 +08:00
|
|
|
# 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.
|