简体   繁体   中英

How to read in sqlite information in javascript without writing your own API?

Most of my experience with database manipulation has been through node.js, and writing simple APIs for class. I'm now trying a private project, where I would write a database, and read in information from it to display on a website hosted through github. however, for what I'm doing, an API seems unnecessary, as I should be able to upload the database file onto github, and have the website read from that, rather than hosting a node.js server. So, what I'm asking is at a high level, how would I get information from a database into a form I can read onto a website, and would just creating a json locally, or storing the info some other way, be a better solution?

If the database is very large, then this really should be done server side.

If the database is small, one option is to convert the sqlLite database to JSON, and then just use fetch to grab, and just parse using Javascript.

But another option I think you might like, is use a sqLite client compiled for the browser. If your browser is relatively new and supports webAssembly you might find this interesting.

https://github.com/sql-js/sql.js

Basically sqLite compiled for the browser..

One issue with any of these is security, anybody could of course download the JSON or Sqlite database in full and have full access. Server side you can implement user authentication etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM