# How to put a web SQLite database on the client side?

**URL:** <https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784>\
**Category:** Web\
**Created:** [October 21, 2019, 4:52am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784 "2019-10-21T04:52:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Scanlan](https://forum.xojo.com/user_avatar/forum.xojo.com/john_scanlan/32/472_2.png) [@John\_Scanlan](https://forum.xojo.com/u/John_Scanlan)\
**Post date:** [October 21, 2019, 4:52am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/1 "2019-10-21T04:52:48Z")

</div>

Not sure I quite understand this: If I assign an SQLite database in Session does it put the database on the client side? If not, can I put a database on the client side?

---

<div class="post-metadata">

**Author:** ![Barney\_Hyde](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/779978/32.png) [@Barney\_Hyde](https://forum.xojo.com/u/Barney_Hyde)\
**Post date:** [October 21, 2019, 7:36am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/2 "2019-10-21T07:36:05Z")

</div>

Hi John, I’m not aware of it going to the client side ? The SQLite file would normally reside on the server.

Why do you want to put a database file on the server side - what are you trying to do ?

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [October 21, 2019, 10:34am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/3 "2019-10-21T10:34:39Z")

</div>

> [@459450:@John Scanlan](#):
>
> Not sure I quite understand this: If I assign an SQLite database in Session does it put the database on the client side? If not, can I put a database on the client side?

You cant. The web browser makers shied away from WebSQL in favor of IndexedDB to prevent reliance on a particular technology unfortunately.

---

<div class="post-metadata">

**Author:** ![Steve\_Wilson](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/9fc348/32.png) [@Steve\_Wilson](https://forum.xojo.com/u/Steve_Wilson)\
**Post date:** [October 21, 2019, 3:26pm UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/4 "2019-10-21T15:26:03Z")

</div>

You could take a look at Google’s [Lovefield](https://github.com/google/lovefield)  
or [sql.js](https://github.com/kripken/sql.js/) which is a port of SQLite to Webassembly.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [October 21, 2019, 3:56pm UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/5 "2019-10-21T15:56:37Z")

</div>

> [@459521:@Steve Wilson](#):
>
> Google’s Lovefield

Not a SQLite “client side”, but a persistent, in-browser DB, at client side, for sure.

---

<div class="post-metadata">

**Author:** ![John\_Scanlan](https://forum.xojo.com/user_avatar/forum.xojo.com/john_scanlan/32/472_2.png) [@John\_Scanlan](https://forum.xojo.com/u/John_Scanlan)\
**Post date:** [October 22, 2019, 4:32am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/6 "2019-10-22T04:32:59Z")

</div>

The purpose is speed

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [October 22, 2019, 6:24am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/7 "2019-10-22T06:24:09Z")

</div>

i believe spider basic use a memory db and then in can save/load it in to browser cache sandbox. (non persistence at all)

---

<div class="post-metadata">

**Author:** ![Steve\_Wilson](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/9fc348/32.png) [@Steve\_Wilson](https://forum.xojo.com/u/Steve_Wilson)\
**Post date:** [October 22, 2019, 7:44am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/8 "2019-10-22T07:44:23Z")

</div>

> [@459628:@Markus Rauch](#):
>
> i believe spider basic use a memory db and then in can save/load it in to browser cache sandbox. (non persistence at all)

It uses sql.js (as I linked to above) when you compile a web app or SQLite if you’re compiling for Android / iOS.  
With web apps it’s only persistent until the user clears their browser cache, with Android / iOS then it’s truly persistent in a local SQLite file.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [October 22, 2019, 10:50am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/9 "2019-10-22T10:50:14Z")

</div>

> [@459616:@John Scanlan](#):
>
> The purpose is speed

Keep in mind that youll have to do everything custom. All of our controls assume that the data is coming from the server.

Could you explain what youre doing that you need this?

---

<div class="post-metadata">

**Author:** ![John\_Scanlan](https://forum.xojo.com/user_avatar/forum.xojo.com/john_scanlan/32/472_2.png) [@John\_Scanlan](https://forum.xojo.com/u/John_Scanlan)\
**Post date:** [October 23, 2019, 4:13am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/10 "2019-10-23T04:13:43Z")

</div>

As I said speed; so that the program can get information from the client computer instead of constantly sending an sql command to the server.

I think that will speed things up . . . Am I wrong? (remember, knowledgeable amateur here, not like you professionals)

---

<div class="post-metadata">

**Author:** ![John\_Scanlan](https://forum.xojo.com/user_avatar/forum.xojo.com/john_scanlan/32/472_2.png) [@John\_Scanlan](https://forum.xojo.com/u/John_Scanlan)\
**Post date:** [November 9, 2019, 3:11am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/11 "2019-11-09T03:11:00Z")

</div>

Idea: Do SQL Select and put the results in arrays, then get the data from the arrays instead of SQL Selects.

Will the arrays be on the client side or there still be communication to the server?

Would this speed things up?

---

<div class="post-metadata">

**Author:** ![Kyryl\_Pekarov](https://forum.xojo.com/user_avatar/forum.xojo.com/kyryl_pekarov/32/305_2.png) [@Kyryl\_Pekarov](https://forum.xojo.com/u/Kyryl_Pekarov)\
**Post date:** [November 10, 2019, 10:44am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/12 "2019-11-10T10:44:09Z")

</div>

> [@462540:@John Scanlan](#):
>
> Would this speed things up?

I think no.

Perhaps, you can try to put the array in Cookies. I’m still not sure that Xojo will not send it to the server on fetch. It should be tested.

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz\_Fernandez](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz_fernandez/32/328_2.png) [@Ricardo\_Cruz\_Fernandez](https://forum.xojo.com/u/Ricardo_Cruz_Fernandez)\
**Post date:** [November 10, 2019, 1:26pm UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/13 "2019-11-10T13:26:11Z")

</div>

Uhm, I think the problem is we’re proposing solutions to a problem we don’t know. What’s the actual speed issue you’re trying to resolve John?

If you cache database results into arrays (that will live in the server), then you will have to figure out how you’ll invalidate the cache when needed. Put the cached array into cookies, and you’ll end up reaching the browser’s cookies size limit sooner or later.

Speeding up an application needs a profiling analysis. You can profile the server side using fantastic Xojo’s tooling, or the Browser’s Developer Tools for the client side. Write down a list of the performance issues you’ve detected, estimate the effort on fixing them. Then you’ll be able to just attack the less effort/most impact solution. Rinse and repeat.

For example (just an example I don’t know your issue), maybe you’re trying to put the DB into the client because the queries you’re doing are CPU intensive and you’re running out resources on your server, so you can offload the effort to the clients. The solution instead may be adding an index here or there, rewriting the query, using a materialized view, etc.

---

<div class="post-metadata">

**Author:** ![John\_Scanlan](https://forum.xojo.com/user_avatar/forum.xojo.com/john_scanlan/32/472_2.png) [@John\_Scanlan](https://forum.xojo.com/u/John_Scanlan)\
**Post date:** [November 11, 2019, 1:06am UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/14 "2019-11-11T01:06:50Z")

</div>

The array would be on the server side . . . Thanks

---

<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:** [April 29, 2021, 4:08pm UTC](https://forum.xojo.com/t/how-to-put-a-web-sqlite-database-on-the-client-side/50784/15 "2021-04-29T16:08:13Z")

</div>


