Problem description: luasql is used for MySQL databases in the graduation project. Lua uses its own source code. The test code is similar to the following:
-- Load driverrequire "luasql. mySQL "-- create environment objectenv = assert (luasql. mySQL () -- connect to data sourcecon = assert (ENV: connect ("Database", "USR", "password", "192.168.xx.xxx", 3306 )) -- reset our tableres = con: Execute "Drop table people" -- create a new table peopleres = assert (CON: Execute [[Create Table people (name varchar (50 ), email varchar (50)]) -- add a few elementslist = {name = "Jose das couves", email = "jose@couves.com ",}, {name = "Manoel Joaquim", email = "manoel.joaquim@cafundo.com" ,}, {name = "Maria das dores", email = "maria@dores.com" ,},} For I, P in pairs (list) do -- add data to the people table res = assert (CON: Execute (string. format ([insert into people values ('% s',' % s')], p. name, P. email) end -- retrieve a cursorcur = assert (CON: Execute "Select name, email from people") -- get data -- print all rowsrow = cur: Fetch ({}, "A") -- The Rows will be indexed by field names -- the while row doprint (string. format ("Name: % s, e-mail: % s", row. name, row. email) Row = cur: Fetch (row, "A") -- reusing the table of resultsend -- close everythingcur: Close () Con: Close () ENV: Close ()
Connect through a method similar to the above, the program will
row = cur:fetch ({}, "a")
Crash is dropped when the input parameter is "A". Baidu cannot find the cause after N years. Later I saw possible problems on a cmud forum,
Solution:
Lua5.1 has two DLL files: lua5.1.dll and lua51.dll,
When compiling Lua with the source code, there is a problem with the compilation,
It is no problem to link the Lib compiled by the official team to a static library.