github.com/gogf/gf/v2@v2.7.4/contrib/drivers/README.MD (about)

     1  [简体中文](README.zh_CN.MD)
     2  
     3  # Database drivers
     4  
     5  Powerful database drivers for package gdb.
     6  
     7  ## Installation
     8  
     9  Let's take `mysql` for example.
    10  
    11  ```shell
    12  go get -u github.com/gogf/gf/contrib/drivers/mysql/v2
    13  # Easy to copy
    14  go get -u github.com/gogf/gf/contrib/drivers/clickhouse/v2
    15  go get -u github.com/gogf/gf/contrib/drivers/dm/v2
    16  go get -u github.com/gogf/gf/contrib/drivers/mssql/v2
    17  go get -u github.com/gogf/gf/contrib/drivers/oracle/v2
    18  go get -u github.com/gogf/gf/contrib/drivers/pgsql/v2
    19  go get -u github.com/gogf/gf/contrib/drivers/sqlite/v2
    20  go get -u github.com/gogf/gf/contrib/drivers/sqlitecgo/v2
    21  ```
    22  
    23  Choose and import the driver to your project:
    24  
    25  ```go
    26  import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
    27  ```
    28  
    29  Commonly imported at top of `main.go`:
    30  
    31  ```go
    32  package main
    33  
    34  import (
    35  	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
    36  
    37  	// Other imported packages.
    38  )
    39  
    40  func main() {
    41  	// Main logics.
    42  }
    43  ```
    44  
    45  ## Supported Drivers
    46  
    47  ### MySQL/MariaDB/TiDB
    48  
    49  ```go
    50  import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
    51  ```
    52  
    53  ### SQLite
    54  
    55  ```go
    56  import _ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
    57  ```
    58  
    59  #### cgo version
    60  
    61  When the target is a 32-bit Windows system, the cgo version needs to be used.
    62  
    63  ```go
    64  import _ "github.com/gogf/gf/contrib/drivers/sqlitecgo/v2"
    65  ```
    66  
    67  ### PostgreSQL
    68  
    69  ```go
    70  import _ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
    71  ```
    72  
    73  Note:
    74  
    75  - It does not support `Replace` features.
    76  
    77  ### SQL Server
    78  
    79  ```go
    80  import _ "github.com/gogf/gf/contrib/drivers/mssql/v2"
    81  ```
    82  
    83  Note:
    84  
    85  - It does not support `Replace` features.
    86  - It does not support `LastInsertId`.
    87  - It supports server version >= `SQL Server2005`
    88  - 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.
    89  
    90  ### Oracle
    91  
    92  ```go
    93  import _ "github.com/gogf/gf/contrib/drivers/oracle/v2"
    94  ```
    95  
    96  Note:
    97  
    98  - It does not support `Replace` features.
    99  - It does not support `LastInsertId`.
   100  
   101  ### ClickHouse
   102  
   103  ```go
   104  import _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
   105  ```
   106  
   107  Note:
   108  
   109  - It does not support `InsertIgnore/InsertGetId` features.
   110  - It does not support `Save/Replace` features.
   111  - It does not support `Transaction` feature.
   112  - It does not support `RowsAffected` feature.
   113  
   114  ### DM
   115  
   116  ```go
   117  import _ "github.com/gogf/gf/contrib/drivers/dm/v2"
   118  ```
   119  
   120  Note:
   121  
   122  - It does not support `Replace` features.
   123  
   124  ## Custom Drivers
   125  
   126  It's quick and easy, please refer to current driver source.
   127  It's quite appreciated if any PR for new drivers support into current repo.