Skip to content

Instantly share code, notes, and snippets.

@Luzifer
Created March 4, 2015 12:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luzifer/f73e1d4c158590cd38c8 to your computer and use it in GitHub Desktop.
Save Luzifer/f73e1d4c158590cd38c8 to your computer and use it in GitHub Desktop.
Migrate Etherpad-Lite from MySQL to Redis
package main
import (
"database/sql"
"fmt"
"gopkg.in/redis.v2"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db := redis.NewTCPClient(&redis.Options{
Addr: "<your redis address>:6379",
Password: "<your redis pwd>",
DB: 10,
})
my, err := sql.Open("mysql", "<mysqluser>:<mysqlpass>@tcp(<mysqlhost>:3306)/<database>")
if err != nil {
panic(err)
}
defer my.Close()
rows, err := my.Query("SELECT * FROM store")
if err != nil {
panic(err)
}
for rows.Next() {
var key, value string
err = rows.Scan(&key, &value)
if err != nil {
panic(err)
}
db.Set(key, value)
fmt.Printf(".")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment