• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

lua5.3.5安装/初体验

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

官网http://www.lua.org/start.html 参考  https://blog.csdn.net/qq_23954569/article/details/70879672

cd ~
sudo apt-get install -y libreadline7 libreadline-dev
wget http://www.lua.org/ftp/lua-5.3.5.tar.gz
tar zxf lua-5.3.5.tar.gz
cd lua-5.3.5
sudo make linux test
sudo make install

因为放在了home,所以重装之后,只需要执行最后1句就OK了

包管理luarocks

才1M

cd ~
wget https://luarocks.org/releases/luarocks-3.0.4.tar.gz
tar zxpf luarocks-3.0.4.tar.gz
cd luarocks-3.0.4
./configure; sudo make bootstrap
sudo luarocks install luasocket

 安装luasql-postgres

安装时要求本地有postgres源码 

Error: Could not find header file for PGSQL
No file libpq-fe.h in /usr/local/include
No file libpq-fe.h in /usr/include
No file libpq-fe.h in /include
You may have to install PGSQL in your system and/or pass PGSQL_DIR or PGSQL_INCDIR to the luarocks command.
Example: luarocks install luasql-postgres PGSQL_DIR=/usr/local

但是我的pg是在docker镜像里的, 所以怎么办呢?要么在host上装pg,但完全没必要.超极本上资源已经很紧了,只写代码,不做数据库.

在安装时指定PG路径, 注意不是PGSQL_DIR

sudo apt-get install libpq-dev
sudo luarocks install luasql-postgres PGSQL_INCDIR=/usr/include/postgresql PGSQL_LIBDIR=/usr/lib

连接db简单使用

 

luasql = require "luasql.postgres"
env = assert(luasql.postgres())
-- database user pwd host port
conn = assert(env:connect("postgres","postgres","example",'127.0.0.1'))

-- version
cur = conn:execute("SELECT version();")
print(cur:fetch())

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Lua和C++交互详细总结【转载】发布时间:2022-07-22
下一篇:
lua学习笔记发布时间:2022-07-22
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap