gluadb

package module
v0.0.0-...-9586fc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2018 License: MIT Imports: 4 Imported by: 2

README

glua-db

MySQL and Redis client for gopher lua

require

go get github.com/zhu327/gluadb

document

https://github.com/openresty/lua-resty-mysql

https://github.com/openresty/lua-resty-redis

example

package main

import (
    "github.com/BixData/gluabit32"
    "github.com/BixData/gluasocket"
    "github.com/yuin/gopher-lua"
    "github.com/zhu327/gluadb"
)

func main() {
    L := lua.NewState()
    gluasocket.Preload(L)
    gluabit32.Preload(L)
    gluadb.Preload(L)
    defer L.Close()
    if err := L.DoString(`

    local mysql = require "mysql"
    local db = mysql:new()

    local ok, err, errcode, sqlstate = db:connect{
        host = "127.0.0.1",
        port = 3306,
        database = "mysql",
        user = "root",
        password = "",
        charset = "utf8",
        max_packet_size = 1024 * 1024,
    }

    local res, err, errcode, sqlstate =
        db:query("select * from db", 10)

    print(#res)
    print(res[1].Host)

    db:close()

    local redis = require "redis"
    local red = redis:new()
    local ok, err = red:connect("127.0.0.1", 6379)
    ok, err = red:set("dog", "an animal")
    local res, err = red:get("dog")
    print(res)

    `); err != nil {
        panic(err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Preload

func Preload(L *lua.LState)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL