Skip to content

DGKSK8LIFE/redisql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

78cb675 · Oct 18, 2021
Sep 26, 2021
Oct 4, 2021
Oct 18, 2021
Jul 9, 2021
Sep 11, 2021
Jul 2, 2021
Oct 18, 2021
Sep 28, 2021
Oct 4, 2021
Sep 9, 2021
Sep 9, 2021

Repository files navigation


Example Usage

CLI

Installation and Configuration:

go install github.com/DGKSK8LIFE/redisql/redisql

Create a YAML file with the following structure:

sqltype:
sqluser: 
sqlpassword: 
sqldatabase:
sqlhost:
sqlport:
sqltable:
redisaddr:
redispass:
log_level:
log_filenane:

(log_level and log_filename are optional. Default logging is none and default output is stdout)

Logging Levels:

  • 0 - no logging at all
  • 1 - summary of actions being performed by redisql
  • 2 - all actions (including individual keys and their values being performed by redisql

Usage:

# copy to redis string
redisql copy -type=string -config=pathtofile.yml 

# copy to redis list
redisql copy -type=list -config=pathtofile.yml

# copy to redis hash
redisql copy -type=hash -config=pathtofile.yml

Library

Installation:

go get github.com/DGKSK8LIFE/redisql

Usage:

package main

import (
    "github.com/DGKSK8LIFE/redisql"
)

func main() {
	config := redisql.Config{
		SQLType:     "mysql",
		SQLUser:     "root",
		SQLPassword: "password",
		SQLDatabase: "users",
		SQLHost:     "localhost",
		SQLPort:     "3306",
		SQLTable:    "user",
		RedisAddr:   "localhost:6379",
		RedisPass:   "",
	}
	err := config.CopyToString()
	if err != nil {
		panic(err)
	}
}

Other Methods:

// copy to redis list
config.CopyToList()

// copy to redis hash
config.CopyToHash()

Contributing

Check out CONTRIBUTING

Current Functionality and Limitations

  • Copying of entire SQL tables to Redis via CLI and Go Module
  • Support for most commonly used Redis data types (strings, lists, hashes)
  • Support for Postgres and MySQL
  • Advanced logging with levels and optional file output
  • Autosync
  • Dockerization