https://github.com/dolmen-go/mylogin-driver
A database/sql driver that wraps github.com/go-sql-driver/mysql with a connection string refering to a ~/.mylogin section
https://github.com/dolmen-go/mylogin-driver
database-driver go golang mylogin mysql sql
Last synced: 4 months ago
JSON representation
A database/sql driver that wraps github.com/go-sql-driver/mysql with a connection string refering to a ~/.mylogin section
- Host: GitHub
- URL: https://github.com/dolmen-go/mylogin-driver
- Owner: dolmen-go
- License: apache-2.0
- Created: 2018-06-14T13:29:47.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-10T12:39:54.000Z (about 2 years ago)
- Last Synced: 2025-08-14T10:26:06.953Z (11 months ago)
- Topics: database-driver, go, golang, mylogin, mysql, sql
- Language: Go
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mylogin-driver - Go database/sql driver for MySQL loading credentials from ~/.mylogin.cnf
[](https://pkg.go.dev/github.com/dolmen-go/mylogin-driver)
[](https://travis-ci.org/dolmen-go/mylogin-driver)
[](https://goreportcard.com/report/github.com/dolmen-go/mylogin-driver)
`mylogin-driver` provides a MySQL driver for
[`database/sql`](https://golang.org/pkg/database/sql/).
This is just a wrapper around
[`github.com/go-sql-driver/mysql`](https://github.com/go-sql-driver/mysql) with
a different connection string syntax that allows to read server address and
credentials from `~/.mylogin.cnf`.
About mylogin.cnf:
-
-
See also package [`github.com/dolmen-go/mylogin`](https://pkg.go.dev/github.com/dolmen-go/mylogin)
that provides low-level access to `~/.mylogin.cnf` reading and writing.
## Usage
```go
import (
"database/sql"
_ "github.com/dolmen-go/mylogin-driver/register"
)
db, err := sql.Open("mylogin", "[filepath//]/[]")
```
## Example
Here is an example with the
[public MySQL server provided by ensembl.org](https://www.ensembl.org/info/data/mysql.html).
Create MySQL credentials in a section named `client_ensembl` in `~/.mylogin.cnf`:
```sh
$ mysql_config_editor set -G client_ensembl -h ensembldb.ensembl.org -P 5306 -u anonymous -p
$ cat >main.go <
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.