This example accompanies the Lua-SQLite and LSP Considerations tutorial. It focuses on sharing database access safely and on understanding the practical effects of SQLite locking. For additional background on locking behavior, see Understanding SQLITE_BUSY.
www/.preload- Initializes the shared SQLite setup for the application.www/index.lsp- Example page used to insert data manually or automatically.
Start the example with the Mako Server:
cd SQLite/Shared-Connection
mako -l::wwwFor more detail on starting the Mako Server, see the command line video tutorial and the command line options documentation.
After the server starts:
- Open
http://localhost. - The database starts out empty. Enter data and submit the form to insert rows.
- To automate insertion, open
http://localhost?auto=. - The browser-side JavaScript then begins posting new data automatically as soon as the page loads.
The example keeps a shared SQLite access path in the application and uses index.lsp to drive concurrent or repeated writes. The optional ?auto= mode is there to make locking behavior easier to observe under repeated requests.
- If you encounter busy or locked-database behavior, that is part of the lesson this example is designed to illustrate.
- Use the referenced articles to compare this shared-connection pattern with simpler per-request approaches.