Python sqlite3 database lockedHow do I unlock a SQLite database?How to list the tables in a SQLite database file that was opened with ATTACH?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?
How can my android "die" permanently?
What is the better way to use Optional in conditions?
Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback
What does "play with your toy’s toys" mean?
Has there been any indication at all that further negotiation between the UK and EU is possible?
Why do textbooks often include the solutions to odd or even numbered problems but not both?
Find the probability that the 8th woman to appear is in 17th position.
How do I turn off a repeating trade?
(Newbie question)Why is voltage measurement of circuit different when switch is on?
Is this one of the engines from the 9/11 aircraft?
Folding basket - is there such a thing?
Why do some professors with PhDs leave their professorships to teach high school?
What is the legal status of travelling with methadone in your carry-on?
What was the Shuttle Carrier Aircraft escape tunnel?
Can Ogre clerics use Purify Food and Drink on humanoid characters?
How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?
Would it be a copyright violation if I made a character’s full name refer to a song?
How do I professionally let my manager know I'll quit over smoking in the office?
What does the hyphen "-" mean in "tar xzf -"?
How many people are necessary to maintain modern civilisation?
Trainee keeps missing deadlines for independent learning
Applicability of Lagrange Multipliers in the analysis of large-scale MILPs?
Find the C-factor of a vote
Given a cell in a Voronoi diagram, which point did it come from?
Python sqlite3 database locked
How do I unlock a SQLite database?How to list the tables in a SQLite database file that was opened with ATTACH?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using Python 3 and sqlite3 on Windows. I am developing a small application that is using a database to store contacts. I notice that if the application closes forcibly (either by error or ending via task manager) that I get the sqlite3 error (sqlite3.OperationalError: database is locked).
I imagine this is because I am not properly closing the database connection before the application has closed. I have tried this:
connection = sqlite3.connect(dbFile.db)
connection.commit()
connection.close()
and then trying to reopen the connection, but the locked database remains. Is there anyway to close the database before a crash? Or a way to unlock the database in the application? Right now the only solution I have is to delete the database and start over (which will not really work long term).
Thanks!
python python-3.x sqlite
add a comment |
I am using Python 3 and sqlite3 on Windows. I am developing a small application that is using a database to store contacts. I notice that if the application closes forcibly (either by error or ending via task manager) that I get the sqlite3 error (sqlite3.OperationalError: database is locked).
I imagine this is because I am not properly closing the database connection before the application has closed. I have tried this:
connection = sqlite3.connect(dbFile.db)
connection.commit()
connection.close()
and then trying to reopen the connection, but the locked database remains. Is there anyway to close the database before a crash? Or a way to unlock the database in the application? Right now the only solution I have is to delete the database and start over (which will not really work long term).
Thanks!
python python-3.x sqlite
is the file in a mounted directory? sometime that can be an issue
– MEdwin
Mar 25 at 9:03
The file is on a secondary hard drive (d). This could be the case. Is there any means of avoiding this or should I always save these files on the c drive. Thanks!
– SpaceyEeyore
Mar 26 at 0:25
add a comment |
I am using Python 3 and sqlite3 on Windows. I am developing a small application that is using a database to store contacts. I notice that if the application closes forcibly (either by error or ending via task manager) that I get the sqlite3 error (sqlite3.OperationalError: database is locked).
I imagine this is because I am not properly closing the database connection before the application has closed. I have tried this:
connection = sqlite3.connect(dbFile.db)
connection.commit()
connection.close()
and then trying to reopen the connection, but the locked database remains. Is there anyway to close the database before a crash? Or a way to unlock the database in the application? Right now the only solution I have is to delete the database and start over (which will not really work long term).
Thanks!
python python-3.x sqlite
I am using Python 3 and sqlite3 on Windows. I am developing a small application that is using a database to store contacts. I notice that if the application closes forcibly (either by error or ending via task manager) that I get the sqlite3 error (sqlite3.OperationalError: database is locked).
I imagine this is because I am not properly closing the database connection before the application has closed. I have tried this:
connection = sqlite3.connect(dbFile.db)
connection.commit()
connection.close()
and then trying to reopen the connection, but the locked database remains. Is there anyway to close the database before a crash? Or a way to unlock the database in the application? Right now the only solution I have is to delete the database and start over (which will not really work long term).
Thanks!
python python-3.x sqlite
python python-3.x sqlite
asked Mar 25 at 8:55
SpaceyEeyoreSpaceyEeyore
113 bronze badges
113 bronze badges
is the file in a mounted directory? sometime that can be an issue
– MEdwin
Mar 25 at 9:03
The file is on a secondary hard drive (d). This could be the case. Is there any means of avoiding this or should I always save these files on the c drive. Thanks!
– SpaceyEeyore
Mar 26 at 0:25
add a comment |
is the file in a mounted directory? sometime that can be an issue
– MEdwin
Mar 25 at 9:03
The file is on a secondary hard drive (d). This could be the case. Is there any means of avoiding this or should I always save these files on the c drive. Thanks!
– SpaceyEeyore
Mar 26 at 0:25
is the file in a mounted directory? sometime that can be an issue
– MEdwin
Mar 25 at 9:03
is the file in a mounted directory? sometime that can be an issue
– MEdwin
Mar 25 at 9:03
The file is on a secondary hard drive (d). This could be the case. Is there any means of avoiding this or should I always save these files on the c drive. Thanks!
– SpaceyEeyore
Mar 26 at 0:25
The file is on a secondary hard drive (d). This could be the case. Is there any means of avoiding this or should I always save these files on the c drive. Thanks!
– SpaceyEeyore
Mar 26 at 0:25
add a comment |
1 Answer
1
active
oldest
votes
If your application closes forcibly, surly you wouldn't want to commit your current transaction, instead rollback to insure nothing breaks?
After a signal for a close has been caught, try the following:
connection.rollback()
connection.close()
the code except I had found somewhere else (you're definitely right in that I don't want to commit, I am simply trying to release the lock). The issue I'm having is when developing this application I may not have caught an error and the application already has forcibly closed and want a way to unlock or reset without having to delete the file.
– SpaceyEeyore
Mar 26 at 0:24
Check out this. It seem that your program dying during an operation that locks the database is undefined behaviour. Options I could suggest: Improve error handling in your program to insure you dont forcibly quit during a heavy sql operation. After an unexpected quit, on startup have your program check if there is a process using the database, and kill it.
– Alex Hodges
Apr 1 at 12:00
That is a good suggestion. I think it would be wise to better error handling, issue arises during my debugging sessions when I have been adding new code and wanting to test a new feature.
– SpaceyEeyore
Apr 2 at 19:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334178%2fpython-sqlite3-database-locked%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If your application closes forcibly, surly you wouldn't want to commit your current transaction, instead rollback to insure nothing breaks?
After a signal for a close has been caught, try the following:
connection.rollback()
connection.close()
the code except I had found somewhere else (you're definitely right in that I don't want to commit, I am simply trying to release the lock). The issue I'm having is when developing this application I may not have caught an error and the application already has forcibly closed and want a way to unlock or reset without having to delete the file.
– SpaceyEeyore
Mar 26 at 0:24
Check out this. It seem that your program dying during an operation that locks the database is undefined behaviour. Options I could suggest: Improve error handling in your program to insure you dont forcibly quit during a heavy sql operation. After an unexpected quit, on startup have your program check if there is a process using the database, and kill it.
– Alex Hodges
Apr 1 at 12:00
That is a good suggestion. I think it would be wise to better error handling, issue arises during my debugging sessions when I have been adding new code and wanting to test a new feature.
– SpaceyEeyore
Apr 2 at 19:06
add a comment |
If your application closes forcibly, surly you wouldn't want to commit your current transaction, instead rollback to insure nothing breaks?
After a signal for a close has been caught, try the following:
connection.rollback()
connection.close()
the code except I had found somewhere else (you're definitely right in that I don't want to commit, I am simply trying to release the lock). The issue I'm having is when developing this application I may not have caught an error and the application already has forcibly closed and want a way to unlock or reset without having to delete the file.
– SpaceyEeyore
Mar 26 at 0:24
Check out this. It seem that your program dying during an operation that locks the database is undefined behaviour. Options I could suggest: Improve error handling in your program to insure you dont forcibly quit during a heavy sql operation. After an unexpected quit, on startup have your program check if there is a process using the database, and kill it.
– Alex Hodges
Apr 1 at 12:00
That is a good suggestion. I think it would be wise to better error handling, issue arises during my debugging sessions when I have been adding new code and wanting to test a new feature.
– SpaceyEeyore
Apr 2 at 19:06
add a comment |
If your application closes forcibly, surly you wouldn't want to commit your current transaction, instead rollback to insure nothing breaks?
After a signal for a close has been caught, try the following:
connection.rollback()
connection.close()
If your application closes forcibly, surly you wouldn't want to commit your current transaction, instead rollback to insure nothing breaks?
After a signal for a close has been caught, try the following:
connection.rollback()
connection.close()
answered Mar 25 at 11:49
Alex HodgesAlex Hodges
504 bronze badges
504 bronze badges
the code except I had found somewhere else (you're definitely right in that I don't want to commit, I am simply trying to release the lock). The issue I'm having is when developing this application I may not have caught an error and the application already has forcibly closed and want a way to unlock or reset without having to delete the file.
– SpaceyEeyore
Mar 26 at 0:24
Check out this. It seem that your program dying during an operation that locks the database is undefined behaviour. Options I could suggest: Improve error handling in your program to insure you dont forcibly quit during a heavy sql operation. After an unexpected quit, on startup have your program check if there is a process using the database, and kill it.
– Alex Hodges
Apr 1 at 12:00
That is a good suggestion. I think it would be wise to better error handling, issue arises during my debugging sessions when I have been adding new code and wanting to test a new feature.
– SpaceyEeyore
Apr 2 at 19:06
add a comment |
the code except I had found somewhere else (you're definitely right in that I don't want to commit, I am simply trying to release the lock). The issue I'm having is when developing this application I may not have caught an error and the application already has forcibly closed and want a way to unlock or reset without having to delete the file.
– SpaceyEeyore
Mar 26 at 0:24
Check out this. It seem that your program dying during an operation that locks the database is undefined behaviour. Options I could suggest: Improve error handling in your program to insure you dont forcibly quit during a heavy sql operation. After an unexpected quit, on startup have your program check if there is a process using the database, and kill it.
– Alex Hodges
Apr 1 at 12:00
That is a good suggestion. I think it would be wise to better error handling, issue arises during my debugging sessions when I have been adding new code and wanting to test a new feature.
– SpaceyEeyore
Apr 2 at 19:06
the code except I had found somewhere else (you're definitely right in that I don't want to commit, I am simply trying to release the lock). The issue I'm having is when developing this application I may not have caught an error and the application already has forcibly closed and want a way to unlock or reset without having to delete the file.
– SpaceyEeyore
Mar 26 at 0:24
the code except I had found somewhere else (you're definitely right in that I don't want to commit, I am simply trying to release the lock). The issue I'm having is when developing this application I may not have caught an error and the application already has forcibly closed and want a way to unlock or reset without having to delete the file.
– SpaceyEeyore
Mar 26 at 0:24
Check out this. It seem that your program dying during an operation that locks the database is undefined behaviour. Options I could suggest: Improve error handling in your program to insure you dont forcibly quit during a heavy sql operation. After an unexpected quit, on startup have your program check if there is a process using the database, and kill it.
– Alex Hodges
Apr 1 at 12:00
Check out this. It seem that your program dying during an operation that locks the database is undefined behaviour. Options I could suggest: Improve error handling in your program to insure you dont forcibly quit during a heavy sql operation. After an unexpected quit, on startup have your program check if there is a process using the database, and kill it.
– Alex Hodges
Apr 1 at 12:00
That is a good suggestion. I think it would be wise to better error handling, issue arises during my debugging sessions when I have been adding new code and wanting to test a new feature.
– SpaceyEeyore
Apr 2 at 19:06
That is a good suggestion. I think it would be wise to better error handling, issue arises during my debugging sessions when I have been adding new code and wanting to test a new feature.
– SpaceyEeyore
Apr 2 at 19:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334178%2fpython-sqlite3-database-locked%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
is the file in a mounted directory? sometime that can be an issue
– MEdwin
Mar 25 at 9:03
The file is on a secondary hard drive (d). This could be the case. Is there any means of avoiding this or should I always save these files on the c drive. Thanks!
– SpaceyEeyore
Mar 26 at 0:25