Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

AltStyle によって変換されたページ (->オリジナル) /