10000 GitHub - smallfish/lua-resty-postgres: Lua PostgreSQL client library, based on LuaJIT/libpq
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

smallfish/lua-resty-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Name

lua-resty-postgres - Lua PostgreSQL client library, based on LuaJIT/libpq

Status

This library is considered experimental and still under active development.

The API is still in flux and may change without notice.

Synopsis

local cjson    = require 'cjson'
local postgres = require 'resty.postgres'

local strfmt   = string.format

local db, err = postgres:connect('host=localhost user=xx dbname=xx')
if err then
    -- has error, exit
end

local version, err = db:version()
if not err then
    print(cjson.encode(version))
    -- out:
    -- {"lib":90601, "server":90601}
end

local rows, err = db:query('SELECT tableowner, tablename FROM pg_tables LIMIT 2')
if not err then
    print(cjson.encode(rows))
    -- out:
    -- [{"tablename":"products","tableowner":"xx"},{"tablename":"pg_statistic","tableowner":"postgres"}}]
end

local num, err = db:execute("UPDATE xx SET xx='hahaha' WHERE xx=xx")
-- check error
if not err then
    print('update rows:' .. num)
end

db:close()

Dependencies

This library depends on the following Lua libraries:

Back to TOC

Author

Copyright (C) 2016, by Chen "smallfish" Xiaoyu (陈小玉) smallfish.xy@gmail.com

Back to TOC

About

Lua PostgreSQL client library, based on LuaJIT/libpq

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0