gsql

command module
v0.0.0-...-187f65c Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 12 Imported by: 0

README

Go SQL Executor

Execute SQL in Lua VM.

Lua example

local sql = require("sql")

local c = sql.new()
local ok, err = c:connect("mssql",
    "Server=tcp:127.0.0.1,1433;Database=<database>;User ID=<user>;Password=<password>;Integrated Security=false;")
if ok then
    local tx = c:begin_tx()
    if tx ~= nil then
        _, err = tx:exec("update User set name = 'User Name' where UserProfileId=1")
        if err ~= nil then
            print(err)
            tx:rollback()
        end
        tx:commit()
    end
else
    print(err)
end
c:close()

Usefull functions

function dumpTable(table, depth)
    if (depth > 200) then
        print("Error: Depth > 200 in dumpTable()")
        return
    end
    for k, v in pairs(table) do
        if (type(v) == "table") then
            print(string.rep("  ", depth) .. k .. ":")
            dumpTable(v, depth + 1)
        else
            print(string.rep("  ", depth) .. k .. ": ", v)
        end
    end
end

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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