Rick Posted January 2, 2012 Share Posted January 2, 2012 File Name: SQLite for LE's Lua File Submitter: Rick File Submitted: 02 Jan 2012 File Category: Scripts I've compiled this with VS 2010 Express C++ (so probably need those run-times) and LuaJIT (the same version LE uses). To see the usage look at the below website: http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki#examples You can use any SQLite browser (there are a bunch of free ones and some plugins for Chrome and Firefox) to see the data inside it. Note the difference in loading the lib from the examples. -- load sqlite dll package.loadlib("C:\\Leadwerks Engine SDK\\lsqlite3.dll", "luaopen_lsqlite3")() -- if db doesn't exist it'll create it in the same directory as the editor/engine local db = sqlite3.open('MyDatabase.sqlite3') -- run these commands db:exec[[ CREATE TABLE test (id INTEGER PRIMARY KEY, content); INSERT INTO test VALUES (NULL, 'Hello World'); INSERT INTO test VALUES (NULL, 'Hello Lua'); INSERT INTO test VALUES (NULL, 'Hello Sqlite3') ]] -- show the above results for row in db:nrows("SELECT * FROM test") do Notify(row.id.." "..row.content) end db:close() I'm currently using this to store persistent data in my game as it's really easy to read and write data like this. It's simply an alternative to using xml or any other kind of file. SQLite is a database system that is simply just 1 file (with the structure of a database and all the wonderful SQL benefits). It's crossplatform and very simple to use. Have fun! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.