Replies: 2 comments
-
BEGIN...COMMIT defines a transaction in SQL, so whether you use that or not depends on what operations on your database you want to be semantically atomic. That's really a question for your particular application and has nothing to do with closing the database. Closing any resource you open is good software development practice in general. However, in the typical case of a web app that uses a single database until dismissed, there is no practical drawback for leaving it open.
There is currently no example code in this repo for this and I have no plans to add it. I would probably approach it by instantiating a VFS and calling its methods - xOpen, xLock, xFileSize, xSectorSize, xRead, xUnlock, xClose - to read data in sector sized chunks...but that requires an understanding of both the SQLite VFS interface and how wa-sqlite adapts it to Javascript. A less general but probably easier way to do it would be to copy the code that opens the IndexedDB database and then read the blocks directly with the IndexedDB API. Using wa-sqlite in a Worker is no different than using it in a Window, except that you will need to bundle your Javascript because not all browsers support ES modules in Workers. There is a FAQ item about that. |
Beta Was this translation helpful? Give feedback.
-
Hi @rhashimoto and thanks for your reply ! 🙏🏻 Noted about I came to same conclusion about About saving to an sqlite file - I read closely (and googled) the 2 approaches that you described. I think both are beyond my current skill level. But if anyone else writes some code there - I will eagerly test it for them 😁 There is an easier approach - I know it would be far less of a complete solution - and that is table by table, with the goal to just save as a CSV. That CSV then can be easily imported anywhere, without code, so data is not lost. As long as can just get it showing in the browser as a RAW csv file, can (manually) do a save-page-as. Even that is just out of reach of my current skills, but I will try to do it one weekend in the future when I am stuck in the house by rains and flood (unless someone else does it first). "Using wa-sqlite in a Worker is no different than using it in a Window, except that you will need to bundle your Javascript because not all browsers support ES modules in Workers. There is a #4. " That is GREAT NEWS ! ❤ thanks again 🙏🏻 |
Beta Was this translation helpful? Give feedback.
-
Hi there ! and what a great project is wa-sqlite ! 😁😁
I am loving it, and all thanks to @rhashimoto for his work.
Mostly my project (porting a bunch of old access sql tools) is working now on
wa-sqlite
- and it only took a couple of days of work to get to that point. For me - data persistence, and the ease to get it running are the important parts. I am not a JS coder, I tinker with JS maybe once or twice a year. It was easy enough to get running, and WA-sqlite is plenty fast ! I tried to do it first withabsurb-sql
they boast lightning speed, but after a few days of configuring, i could never quite get it running.. In contrastwa-sqlite
was up and running within first couple attempts, and really did not show signs of trouble (for someone inexperienced/unskilled).So I am very very grateful to @rhashimoto thx ! 🙏🏻
The next part of the plan - is to convert to PWA... Which I have never done before. But I believe the first step is putting all JS into worker threads. So that is the plan.... My JS is all just interacting with the SQlite db stored in indexedDb.... using
wa-sqlite
.Please any advice ? tips ? samples ? examples ? thoughts ? or comments about how I should approach this task. Any comments would be warmly received.
Chat-GPT3 told me that it should be easy 🙄 I prefer to trust humans 🙏🏻😊
Two other unrelated questions - which (further) demonstrate my near-beginner skill-level: 😂
and then never close that db or do anything else about the connection. Is that the usual way of doing it ?
Beta Was this translation helpful? Give feedback.
All reactions