# Forcing a commit on a SQLiteDatabase isn't working?

**URL:** <https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522>\
**Category:** iOS\
**Created:** [December 7, 2015, 5:20pm UTC](https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522 "2015-12-07T17:20:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Iwaniec](https://forum.xojo.com/user_avatar/forum.xojo.com/tom_iwaniec/32/345_2.png) [@Tom\_Iwaniec](https://forum.xojo.com/u/Tom_Iwaniec)\
**Post date:** [December 7, 2015, 5:20pm UTC](https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522/1 "2015-12-07T17:20:24Z")

</div>

I’m not sure if this is a bug or something else, but I’m having issues with the new SQLiteDatabase always storing logged changes in the -shm and -wal files even after using `myDB.SQLExecute("COMMIT")` and after closing out the database connection completely. I can’t seem to get those files/changes to be rolled into the main database file no matter what I’m doing.

This is on 2015r3.1

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [December 7, 2015, 5:36pm UTC](https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522/2 "2015-12-07T17:36:32Z")

</div>

My first thought is that you have an error in the SQL and you’re not checking for the database error. Committing will do nothing if you have an error.

Show us the code you have right before you’re trying to commit.

---

<div class="post-metadata">

**Author:** ![Tom\_Iwaniec](https://forum.xojo.com/user_avatar/forum.xojo.com/tom_iwaniec/32/345_2.png) [@Tom\_Iwaniec](https://forum.xojo.com/u/Tom_Iwaniec)\
**Post date:** [December 7, 2015, 5:55pm UTC](https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522/3 "2015-12-07T17:55:11Z")

</div>

I’m not getting any SQL errors and the changes are saving correctly (to the shm/wal files). I’m not even trying to do these as BEGIN/COMMIT transactions for this purpose.

It looks like I need to initiate sqlite3\_wal\_checkpoint\_v2 but I’m having trouble getting that to work.

---

<div class="post-metadata">

**Author:** ![Tom\_Iwaniec](https://forum.xojo.com/user_avatar/forum.xojo.com/tom_iwaniec/32/345_2.png) [@Tom\_Iwaniec](https://forum.xojo.com/u/Tom_Iwaniec)\
**Post date:** [December 7, 2015, 6:27pm UTC](https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522/4 "2015-12-07T18:27:35Z")

</div>

Looks like if I execute a `PRAGMA wal_checkpoint(FULL);` then it works to properly move the changes to the original database, even though WAL and SHM files still exist.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [December 7, 2015, 7:30pm UTC](https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522/5 "2015-12-07T19:30:14Z")

</div>

wal is the write ahead log  
and it still being present almost sounds like you have a begin transaction without a matching close  
otherwise the wal log SHOULD automagically be removed when the commits occur  
See 2.2 and 2.3 here [https://www.sqlite.org/tempfiles.html](https://www.sqlite.org/tempfiles.html)

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:05pm UTC](https://forum.xojo.com/t/forcing-a-commit-on-a-sqlitedatabase-isnt-working/28522/6 "2020-10-29T18:05:45Z")

</div>


