Skip to content

Commit

Permalink
contrib/drivers: add README.zh_CN.MD (#3604)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailaz authored May 27, 2024
1 parent 9e9e42b commit 457f7ab
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 12 deletions.
28 changes: 16 additions & 12 deletions contrib/drivers/README.MD
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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.
125 changes: 125 additions & 0 deletions contrib/drivers/README.zh_CN.MD
Original file line number Diff line number Diff line change
@@ -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` 功能。

## 自定义驱动程序

自定义驱动程序非常快速和简单,您可以参考当前驱动程序的源代码来进行开发。
如果您有关于支持新驱动程序的PR(Pull Request),我们将非常感激地接受您的提交到当前仓库。

0 comments on commit 457f7ab

Please sign in to comment.