From 9ff3fd64c9216e064290267e388abecbe0effd53 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 1 Nov 2020 15:46:36 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20MySQL:=20Update=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql/README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/mysql/README.md b/mysql/README.md index c64321e4..7f2688ff 100644 --- a/mysql/README.md +++ b/mysql/README.md @@ -1 +1,34 @@ -# mysql +# MySQL + +A MySQL storage driver using `database/sql` and [`go-sql-driver/mysql`](https://github.com/go-sql-driver/mysql). + +### Creation + +To create a new instance of the MySQL store, is is reccomended that you provide a database name, a table name, a username and a password. The database must exist beforehand, but the table will be created if it does not exist. + +```go +// import "github.com/gomodule/redigo/redis" +store := mysql.New(mysql.Config{ + DatabaseName: "myDb", + TableName: "thisStore", + Username: "user", + Password: "yourPasswordHere", +}) +``` + +By default the store will connect to a database on `127.0.0.1:3306`. If you are using multiple MySQL stores in your application, it is strongly advised that you use different table names for each, to avoid data being overwritten or otherwise damaged. + +A full list of configuration options and their defaults can be found [in `config.go`](/config.go). + +### Running tests/benchmarks + +Tests and benchmarks for this package require a running MySQL server, and assume you have one at `127.0.0.1:3306`. The following environment variables can be used to configure the tests: + +| Name | Corresponding `Config` option | +| ---------------- | ----------------------------- | +| `MYSQL_ADDRESS` | `Address` | +| `MYSQL_USERNAME` | `Username` | +| `MYSQL_PASSWORD` | `Password` | +| `MYSQL_DATABASE` | `DatabaseName` | + +If a given environment variable is not set, the default value is used. \ No newline at end of file