contrib/drivers: add README.zh_CN.MD (#3604)

This commit is contained in:
海亮 2024-05-27 21:02:02 +08:00 committed by GitHub
parent 9e9e42b45c
commit 457f7abcf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 141 additions and 12 deletions

View File

@ -1,8 +1,10 @@
# drivers
[简体中文](README.zh_CN.MD)
# Database drivers
Powerful database drivers for package gdb.
# Installation
## Installation
Let's take `mysql` for example.
@ -40,27 +42,29 @@ func main() {
}
```
# Supported Drivers
## Supported Drivers
## MySQL/MariaDB/TiDB
### MySQL/MariaDB/TiDB
```go
import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
```
## SQLite
### SQLite
```go
import _ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
```
### cgo version for 32-bit windows
#### cgo version
When the target is a 32-bit Windows system, the cgo version needs to be used.
```go
import _ "github.com/gogf/gf/contrib/drivers/sqlitecgo/v2"
```
## PostgreSQL
### PostgreSQL
```go
import _ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
@ -70,7 +74,7 @@ Note:
- It does not support `Replace` features.
## SQL Server
### SQL Server
```go
import _ "github.com/gogf/gf/contrib/drivers/mssql/v2"
@ -83,7 +87,7 @@ Note:
- 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
### Oracle
```go
import _ "github.com/gogf/gf/contrib/drivers/oracle/v2"
@ -94,7 +98,7 @@ Note:
- It does not support `Replace` features.
- It does not support `LastInsertId`.
## ClickHouse
### ClickHouse
```go
import _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
@ -107,7 +111,7 @@ Note:
- It does not support `Transaction` feature.
- It does not support `RowsAffected` feature.
## DM
### DM
```go
import _ "github.com/gogf/gf/contrib/drivers/dm/v2"
@ -117,7 +121,7 @@ Note:
- It does not support `Replace` features.
# Custom Drivers
## 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.

View File

@ -0,0 +1,125 @@
# 数据库驱动程序
用于gdb包的数据库驱动程序。
## 安装
以 `mysql` 为例。
```shell
go get -u github.com/gogf/gf/contrib/drivers/mysql/v2
# 方便复制
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
```
选择并将驱动程序导入到您的项目中:
```go
import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
```
通常在 `main.go` 的顶部导入:
```go
package main
import (
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
// 其他导入的包。
)
func main() {
// 主要逻辑。
}
```
## 支持的驱动程序
### MySQL/MariaDB/TiDB
```go
import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
```
### SQLite
```go
import _ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
```
#### cgo 版本
32位Windows请使用cgo版本
```go
import _ "github.com/gogf/gf/contrib/drivers/sqlitecgo/v2"
```
### PostgreSQL
```go
import _ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
```
注意:
- 不支持 `Replace` 功能。
### SQL Server
```go
import _ "github.com/gogf/gf/contrib/drivers/mssql/v2"
```
注意:
- 不支持 `Replace` 功能。
- 不支持 `LastInsertId`。
- 仅支持服务器版本 >= `SQL Server2005`
- 仅支持 datetime2 和 datetimeoffset 类型来自动处理 created_at/updated_at/deleted_at 列,因为 datetime 类型在将列值作为字符串传递时不支持微秒精度。
### Oracle
```go
import _ "github.com/gogf/gf/contrib/drivers/oracle/v2"
```
注意:
- 不支持 `Replace` 功能。
- 不支持 `LastInsertId`。
### ClickHouse
```go
import _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
```
注意:
- 不支持 `InsertIgnore/InsertGetId` 功能。
- 不支持 `Save/Replace` 功能。
- 不支持 `Transaction` 功能。
- 不支持 `RowsAffected` 功能。
### DM
```go
import _ "github.com/gogf/gf/contrib/drivers/dm/v2"
```
注意:
- 不支持 `Replace` 功能。
## 自定义驱动程序
自定义驱动程序非常快速和简单,您可以参考当前驱动程序的源代码来进行开发。
如果您有关于支持新驱动程序的PRPull Request我们将非常感激地接受您的提交到当前仓库。