如何检查Lua以查看我与sqlite数据库的连接是否仍然打开?
答案 0 :(得分:4)
LuaSQLite和LuaSQL是Lua最广泛使用的SQLite库。
使用luasqlite是:
sqlite3=require"sqlite3"
db1=sqlite3.open_memory()
db2=sqlite3.open_memory()
db2:close()
print("db1 is ".. (db1:isopen() and "is open" or "it's not open"))
print("db2 is ".. (db2:isopen() and "is open" or "it's not open"))
将luasql与sqlite后端一起使用:
sqlite3=require('luasql.sqlite3')
env=sqlite3.sqlite3()
con1=env:connect(':memory:')
con2=env:connect(':memory:')
con2:close()
print("con1 is ".. (tostring(con1):match'closed' and "not open" or "open"))
print("con2 is ".. (tostring(con2):match'closed' and "not open" or "open"))