.save always errors: database is locked

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

.save always errors: database is locked

Alexander Gabriel
Hi

I do this:

   - restart windows10 or macOS and log in (to guarantee no other process
   is using sqlite3)
   - cd to the folder where sqlite3 v3.29.0 is contained
   - type `sqlite3` (windows 10) or `./sqlite3` (macOS) to start sqlite3
   - type `.open test`, followed by `.save test`

Result: `Error: database is locked`

What am I doing wrong?
How can I change configuration if I can never save changes?

The only time I can save without an error is when I `.save test2` without
having opened it before.

Alex
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: .save always errors: database is locked

Richard Damon
On 8/30/19 9:11 AM, Alexander Gabriel wrote:

> Hi
>
> I do this:
>
>    - restart windows10 or macOS and log in (to guarantee no other process
>    is using sqlite3)
>    - cd to the folder where sqlite3 v3.29.0 is contained
>    - type `sqlite3` (windows 10) or `./sqlite3` (macOS) to start sqlite3
>    - type `.open test`, followed by `.save test`
>
> Result: `Error: database is locked`
>
> What am I doing wrong?
> How can I change configuration if I can never save changes?
>
> The only time I can save without an error is when I `.save test2` without
> having opened it before.
>
> Alex

Databases are different than things like Word Documents. When you issue
command that modify the database, the database on disk is immediately
changed (subject to being in a transaction that can be rolled back), so
you don't need to 'save' a database after working with it. The 'Save'
command is basically similar to the 'Save As' command for a document.

Since the database is current open, trying to save back over the
original copy can't be done, as it is open for reading, and also doesn't
need to be done.

--
Richard Damon

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: .save always errors: database is locked

David Raymond
In reply to this post by Alexander Gabriel
Running sqlite3 will open up an in-memory database to start with.
".open test" will either open the file "test" if it exists, or create the file if it doesn't. You will then be working on that file called "test" which is your database.

The help line for .save is:
.save FILE               Write in-memory database into FILE

".save test" tries to save the current database to the file "test". Since you already have the file "test" open in the CLI tool, when it tries to open it a second time to run the .save command it's getting the "database is locked" error. In fact it seems weird it lets you try at all since at that point you don't have an in-memory database open, but have an actual file open.

Once you do the ".open test" anything you do is done on the "test" file/database. There is no need to save it with .save. "saving" is all through normal database transactions at that point.


-----Original Message-----
From: sqlite-users <[hidden email]> On Behalf Of Alexander Gabriel
Sent: Friday, August 30, 2019 12:11 PM
To: [hidden email]
Subject: [sqlite] .save always errors: database is locked

Hi

I do this:

   - restart windows10 or macOS and log in (to guarantee no other process
   is using sqlite3)
   - cd to the folder where sqlite3 v3.29.0 is contained
   - type `sqlite3` (windows 10) or `./sqlite3` (macOS) to start sqlite3
   - type `.open test`, followed by `.save test`

Result: `Error: database is locked`

What am I doing wrong?
How can I change configuration if I can never save changes?

The only time I can save without an error is when I `.save test2` without
having opened it before.

Alex
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users