# Read only Sqlite DB in Resource Folder?

**URL:** <https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200>\
**Category:** Databases\
**Created:** [November 10, 2018, 4:08pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200 "2018-11-10T16:08:17Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [November 10, 2018, 4:08pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/1 "2018-11-10T16:08:17Z")

</div>

I know it is a no-non (at least on a Mac) to use an SQLite DB file you need to write that is in the Resource folder…

But is there a reason not to leave a small read only SQLite database in the Resource folder and use it from there on either a Mac or Windows?

Thanks,  
Karen

---

<div class="post-metadata">

**Author:** ![Javier\_Menéndez](https://forum.xojo.com/user_avatar/forum.xojo.com/javier_men%C3%A9ndez/32/153_2.png) [@Javier\_Menéndez](https://forum.xojo.com/u/Javier_Men%C3%A9ndez)\
**Post date:** [November 10, 2018, 5:05pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/2 "2018-11-10T17:05:29Z")

</div>

You can do that without problem, as long you dont write (on signed apps)

Javier

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [November 10, 2018, 5:13pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/3 "2018-11-10T17:13:44Z")

</div>

I thought SQLite created a journal file, regardless… since it doesn’t “know” that you are not going to write to it  
and that that journal file was created (ie. IT is written) at the same location as the database

---

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [November 10, 2018, 5:16pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/4 "2018-11-10T17:16:47Z")

</div>

Thanks Javier.

I thought that was the case, but i was not sure

- karen

---

<div class="post-metadata">

**Author:** ![Javier\_Menéndez](https://forum.xojo.com/user_avatar/forum.xojo.com/javier_men%C3%A9ndez/32/153_2.png) [@Javier\_Menéndez](https://forum.xojo.com/u/Javier_Men%C3%A9ndez)\
**Post date:** [November 10, 2018, 5:23pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/5 "2018-11-10T17:23:13Z")

</div>

SQLite only creates additional files when WAL is activated, but I think this is not the case. Is the same when SQLite is used on iOS sandboxed apps: no WAL (multiuser) access possible.

Javier

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 10, 2018, 7:16pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/6 "2018-11-10T19:16:40Z")

</div>

Dave is correct, connecting to SQLite with Xojo creates the extra files whether you like it or not. I have had an app rejected from the MAS because I forgot about this. It’s not hard to work around. Copy the sqlite database out of the app to either app support or temporary to open it.

---

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [November 10, 2018, 7:25pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/7 "2018-11-10T19:25:44Z")

</div>

> [@413672:@Tim Parnell](#):
>
> Dave is correct, connecting to SQLite with Xojo creates the extra files whether you like it or not. I have had an app rejected from the MAS because I forgot about this. It’s not hard to work around. Copy the sqlite database out of the app to either app support or temporary to open it.

I will test it then …

From what I’ve read of the Sqlite docs, I was under the impression that it only created the extra file if you used WAL… but of course Xojo inc could change that in its plugin which is why I asked…

If the plugin’s behavior in that respect is different from that of SQLite itself, that should be documented in the language reference,

In any case if it’s not needed by SQLite, Xojo’s plugin should avoid doing it if possible.

BTW for DB’s I’m going to write to (most cases), I do as you suggest… But I did not see the point of doing that for a read-only DB, as it is conceptually no different form any other resource

- Karen

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [November 10, 2018, 8:52pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/8 "2018-11-10T20:52:33Z")

</div>

> [@413672:@Tim Parnell](#):
>
> connecting to SQLite with Xojo creates the extra files

Is this why there is a crash when the db file is in a Read-Only folder ?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 10, 2018, 9:06pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/9 "2018-11-10T21:06:39Z")

</div>

Sounds reasonable to me.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [November 10, 2018, 9:15pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/10 "2018-11-10T21:15:45Z")

</div>

You can open a SQLite database read only and than there would be no journal file as far as I know.

At least for MBS SQL Plug-in we have a flag if I remember correctly.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 10, 2018, 9:18pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/11 "2018-11-10T21:18:14Z")

</div>

> [@413690:@Christian Schmitz](#):
>
> You can open a SQLite database read only and than there would be no journal file as far as I know.

There is no way with pure Xojo though, and that’s where the issue comes from.  
Good to know MBS can do it though! 😃

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [November 10, 2018, 11:22pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/12 "2018-11-10T23:22:48Z")

</div>

found it:

[code]// for SQLite, set flag to open database file read only:

dim c as SQLDatabaseMBS // your database connection  
c.Option(“SQLiteVFSFlags”) = “1”[/code]

Works for SQLite with [SQLDatabaseMBS](http://www.monkeybreadsoftware.net/class-sqldatabasembs.shtml) or [SQLConnectionMBS](http://www.monkeybreadsoftware.net/class-sqlconnectionmbs.shtml) class.

---

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [November 11, 2018, 12:05am UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/13 "2018-11-11T00:05:59Z")

</div>

[quote=413691:@Tim Parnell]There is no way with pure Xojo though, and that’s where the issue comes from.  
[/quote]

As that flag is built into Sqlite there is no reason for Xojo inc not to support it… and the feedback request goes back to July 2012!

\<[https://xojo.com/issue/21814](https://xojo.com/issue/21814)\>

Little things like that make do make a difference in the Xojo experience… but even Apple no longer pays attention to the little things that make a better experience!

- karen

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [November 11, 2018, 12:29am UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/14 "2018-11-11T00:29:54Z")

</div>

> [@413697:@Karen Atkocius](#):
>
> but even Apple no longer pays attention to the little things that make a better experience!

All it takes to create a whole new Operating System is to add more Emoji… As long it it is “pretty”… no one cares.

---

<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, 7:27pm UTC](https://forum.xojo.com/t/read-only-sqlite-db-in-resource-folder/46200/15 "2020-10-29T19:27:22Z")

</div>


