grasshopper3 Posted September 27, 2010 Share Posted September 27, 2010 Hey, I have a quick SQLite question. I am trying to execute two queries on a SQLite database. The first is executed sucessfully, but when the second one fails with an error message, "database is locked". I am currently using _SQLite_Close($Database) and _SQLite_Shutdown() between the two executions. I am not sure why the database is locked. The first execution is an INSERT statement and the second is a DELETE statement. Is there some kind of release functions that I am missing? Thanks Link to comment Share on other sites More sharing options...
KaFu Posted September 27, 2010 Share Posted September 27, 2010 I guess it's just happening what the error code says, the database is locked . The first INSERT statement does not seem to be finalized when you start the DELETE statement. Afaik SQLite supports a parallel reading (select) query, but two writing queries (insert, update, delete) are not allowed at the same time. Did you issue an BEGIN TRANSACTION without a COMMIT TRANSACTION? Maybe also try _SQLite_QueryFinalize()? Hard to say without a code sample ... Here's some reading on the locking mechanism: http://www.sqlite.org/lockingv3.html OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
jchd Posted September 29, 2010 Share Posted September 29, 2010 It's a waste of resources and cycles to perform _close and (even more) _shutdown unnecessarily. Typically, "Database is locked" means that an SQL statement (some SQLite VDBE) is still executing, when you attempt to execute another SQL statement using the same connection. This is a design error. Post simple offending code with irrelevant parts removed and we'll show you what's going on and how to avoid problems. 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...
grasshopper3 Posted September 29, 2010 Author Share Posted September 29, 2010 Thanks for the support! I figured out the problem. I was missing _SQLite_QueryFinalize(). Link to comment Share on other sites More sharing options...
jchd Posted September 29, 2010 Share Posted September 29, 2010 I recommend not using split operations whenever possible. I mean you can generally have your job done by using only higher level function calls: _SQLite_Exec, _SQLite_GetTable[2d] or _SQLite_QuerySingleRow and such. Almost every piece of code I've been shown using "lower level" calls turns out to be less efficient and more error-prone. Of course if your application calls for a more technical tuning, then you can achieve best performance by using _Preparev2 and friends yourself, but this requires careful structure in the code and a really good understanding of the working of the SQLite library itself. 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