Trax Posted March 5, 2022 Share Posted March 5, 2022 Long ago I wrote a AutoIT program that reads temperatures from a device and saves them in a SQLite database 24/7/365. Now they want to access that data. I was very unclear about record locking in SQLite. Can several programs access that SQLite data as long as it is read only without messing up the one that is writing to it? Link to comment Share on other sites More sharing options...
Nine Posted March 5, 2022 Share Posted March 5, 2022 https://www.sqlite.org/lockingv3.html “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
jchd Posted March 5, 2022 Share Posted March 5, 2022 @Traxif you switch your database to WAL mode, using a pragma, you can have many readers and one writer concurrently. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Gianni Posted March 5, 2022 Share Posted March 5, 2022 (edited) 2 hours ago, Trax said: Long ago I wrote a AutoIT program that reads temperatures from a device and saves them in a SQLite database 24/7/365. Now they want to access that data. I was very unclear about record locking in SQLite. Can several programs access that SQLite data as long as it is read only without messing up the one that is writing to it? ...following this nice example (https://www.autoitscript.com/forum/topic/154901-two-processes-sharing-a-file/?do=findComment&comment=1119112) posted by @jchd some time ago, I was able to write some programs with simultaneous reading and writing on the same DB from multiple scripts at the same time. I hope that example can be useful to you too ..... Edited March 5, 2022 by Gianni Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Trax Posted March 5, 2022 Author Share Posted March 5, 2022 OK. I must admit that was a little more involved then I was hoping for. It looks like I am using SQLite 3.31.1 in whatever its default mode is. The database is on a computer on the network and the reading will take place across the network based on a share. The only one writing to the database is the program running on that computer. So I would want to implement WAL? Link to comment Share on other sites More sharing options...
jchd Posted March 5, 2022 Share Posted March 5, 2022 (edited) Yes, but there's one caveat: network support may behave unexpectedly. The problem is that SQLite relies on file locking for proper operation. Many networks don't like that many locking/unlocking requests occuring constantly from several source on the network and may get confused. In practice, I've long used a similar setup as yours and never experienced any problem. As long as remote "clients" don't harrass the host, you should be safe. In any case code defensively by using transactions when required and checking every call for error. You just have to issue the relevant pragma only once since the setting is database-persistent. Edited March 5, 2022 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Trax Posted March 5, 2022 Author Share Posted March 5, 2022 Many thanks @jchd and all Link to comment Share on other sites More sharing options...
Nine Posted March 5, 2022 Share Posted March 5, 2022 (edited) Of course you could make a copy of the DB (once every day like during backup procedure), and use that copy to DW purposes for extracting and sending requests.. Edited March 5, 2022 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
jchd Posted March 6, 2022 Share Posted March 6, 2022 A quick note: an SQLite DB is just a file, BUT when connections are active there may be journaling files created. In WAL mode, there are 2 files for journaling (*.wal and *.shm). To make a complete working copy of a database, use either the backup API or vacuum into. Important warning: I said yes to using a low-concurrency DB over a network with recent Windows OSes. BUT I forgot to explicitely state that WAL mode is incompatible with a network filesystem since it uses memory-mapped journal files. For remote acces you have to use the rollback journal mode. In this mode you can have either many readers OR one writer at a given time. Use short immediate transactions with a very long timeout delay (several minutes). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now