hi agentzh,
我想用openresty 实现一个mysql的http客户端,供内部接口调用,基本思路就是把sql语句通过url送给nginx,然后调用 lua-resty-mysql 查询后把结果用json格式输出。
现在碰到两个问题:
1. db:connect 时使用 path 调用 unix socket连接好象不起作用,具体作法就是配置成 path = "unix:/tmp/mysql.sock" 时报“failed to connect: no such file or directory”,改成 host = "127.0.0.1", port = 3306 就成功了,前提是mysql 授权没问题,已经用 mysql -S /tmp/mysql.sock -u ngx -p 测试了
2. read_result 的结果输出是每行包括完整的 col name 的,类似 php 的 mysql_fetch_assoc 输出,这个会造成结果集比较大,希望能提供类似 mysql_fetch_row 的输出选择,即每行只输出 value,不包括 key。具体到手册中的例子
{
{ name = "Bob", age = 32, phone = ngx.null },
{ name = "Marry", age = 18, phone = "10666372"}
}
希望能输出成
{
{ "Bob", 32, ngx.null },
{ "Marry", 18, "10666372"}
}
谢谢
--
Lance