AuthPlatform/src/api/system/user.lua

34 lines
866 B
Lua

---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by admin.
--- DateTime: 2025/9/25 08:19
---
local db_config = require('config.database')
local pgmoon = require('share.pgmoonn')
-- 创建一个新的连接
local conn = pgmoon.new(db_config.postgres)
-- 连接到数据库
conn:connect(function(err)
if err then
print("Error connecting to database: ", err)
else
print("Connected to the PostgreSQL server.")
-- 执行一个简单的查询
conn:query("SELECT version()")
:on_data(function(row)
print("Database Version: ", row[1])
end)
:on_error(function(err)
print("Query Error: ", err)
end)
:on_finish(function()
print("Query finished.")
-- 关闭连接
conn:close()
end)
end
end)