[SOLVED] Unlocking a Sqlite3 db-file lazarus / 16-Databases ---------------------------------------------------------------------- cdbc · 2021-01-21 18:33 Hi Well, here i go again... I succeeded in locking my sqlite3 database file  Any thoughts on how to unlock it again?!? At the moment, it is readonly. Any help will be appreciated. TIA Regards Benny ---------------------------------------------------------------------- JanRoza · 2021-01-21 18:38 How did you lock it? Are you sure there is no process running that has the database open for Write operations? ---------------------------------------------------------------------- cdbc · 2021-01-22 10:54 Hi I don't know how it got locked ?!? There shouldn't be other processes accessing the db It just suddenly happened... My connection gets created at startup and closed on destroy, I use only 1 connection shared in the entire application. Regards Benny ---------------------------------------------------------------------- af0815 · 2021-01-22 14:31 https://stackoverflow.com/questions/151026/how-do-i-unlock-a-sqlite- database deal with the same problem ---------------------------------------------------------------------- cdbc · 2021-01-22 14:54 Hi Ok, tried that, no luck  I may just have to export the bastard to another db-file  Regards Benny ---------------------------------------------------------------------- JanRoza · 2021-01-22 15:50 You could try to look at your database with a db manager program like the free SQLiteExpert Personal (http://www.sqliteexpert.com/), it lets you manage the locking mode on a database level. Maybe that will help. ---------------------------------------------------------------------- cdbc · 2021-01-22 18:14 Hi Ok, so here's one solution to the problem: Code: [Select]1) Open your terminal and cd to your db-directory 2) Type sqlite3 your_database_name.your_extension     you are now in the sqlite3 management prompt:     SQLite version 3.34.1 2021-01-20 14:10:07     Enter ".help" for usage hints. 3) Type .clone new_database_name.your_extension 4) Type .quit 5) You are now back in terminal 6) Check that your new db works as expected in your     app 7) Delete the old db-file and rename the new one 8) Type exit and "Bob's your uncle" sqlite3 comes with sqlite3 installation Hope that others may find it useful  Regards Benny ---------------------------------------------------------------------- lucamar · 2021-01-22 20:08 A better solution would have been trying to find out what you did to lock it and, if possible, undo it. Having to clone/rename the database without knowing why it happened is just a crutch, IMHO ---------------------------------------------------------------------- cdbc · 2021-01-24 11:29 Hi @lucamar: Oh I did that, and I had accidently introduced an error, that killed the connection in the middle of a transaction  I know, not too clever... Refactoring didn't go so well in this case  It's fixed and all is well. Regards Benny