forked from JamesStewy/go-mysqldump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
47 lines (38 loc) · 1.13 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Create MYSQL dumps in Go without the 'mysqldump' CLI as a dependancy.
Example
This example uses the mymysql driver (example 7 https://github.com/ziutek/mymysql) to connect to a mysql instance.
package main
import (
"database/sql"
"fmt"
"github.com/JamesStewy/go-mysqldump"
"github.com/ziutek/mymysql/godrv"
"time"
)
func main() {
// Register the mymysql driver
godrv.Register("SET NAMES utf8")
// Open connection to database
db, err := sql.Open("mymysql", "tcp:host:port*database/user/password")
if err != nil {
fmt.Println("Error opening databse:", err)
return
}
// Register database with mysqldump
dumper, err := mysqldump.Register(db, "dumps", time.ANSIC, true)
if err != nil {
fmt.Println("Error registering databse:", err)
return
}
// Dump database to file
err = dumper.Dump()
if err != nil {
fmt.Println("Error dumping:", err)
return
}
// Close dumper and connected database
dumper.Close()
}
*/
package mysqldump