connect SQlite database - javascript

Im trying to view database on my web app. The problem here is that it does not view from SQLite. rather view database from chrome add-ons. Is there any way for me to view SQlite databse using Jscript?

There is no way to directly access an arbitrary SQLite database via client side JavaScript running in a web browser.
If your database exists on a webserver, then you can write an HTTP based API (ideally one that is RESTful) and interact with it via the XMLHttpRequest object.

Related

Store and edit data using ReactJS

I am building an application using ReactJS. I am trying to find out how to store data and to edit it. I tried to store it on my computer with 'fs, 'browserify-fs' but it didn't work.
Should I use express, or is there any other alternatives ?
If you are using React you are operating in the browser. Your option for storage is in local storage. This is explained here.
Examples of code are:
// setter
localStorage.setItem('myData', data);
// getter
localStorage.getItem('myData');
// remove
localStorage.removeItem('myData');
// remove all
localStorage.clear();
Note this is stored in the browser and can be easily cleared. You are going to realize that you need a back end solution. This is a server you can send requests to which has an API (a place you send requests to) which executes some form of operation (normally CRUD - Create Read Update Delete via a REST endpoint or GRAPHQL) to serve you back the data you are requesting from a database (MySQL, Postgres, MongoDB). This is a whole different discussion.
To store an array in local storage you will need to make it a string via JSON.stringify. An example would be:
localStorage.setItem("array", JSON.stringify(array));
In developer tools in Chrome you can go to Application -> Storage -> Local Storage and see what is saved. Here is an example:
If you want to share the data along multiple clients you should use server-side solution or if you just want to save the data for a client only you could use client-side solution provided by #diesel.
Create your own web-server
You need to create web server and a database to store your data. Database is used to store data. You could use: MySQL, PostgreSQL, SQLite3, MongoDB, ... You also need to create web service to make secure database calls.
To create web server you could use Express.js to write your web server easily.
Headless Content Management Systems (abbr: CMS)
If you don't want to spent time on creating your own web-server you could install a headless CMS to read/write your data using api endpoints provided by CMSs. Here's list of headless CMS softwares: headlesscms.org. I tried strapi which has lots of features you might need.
Here's some strapi features:
Open-source
Model builder
Extensible (plugin support)
Content editor (eg: to edit articles)
and many more
Firebase
If you don't want to spend your time on installing CMS software to your server and maintaining it regularly you could use Database service provided by Google Firebase. It is also feature rich too. Here's some features supported by Firebase.
NoSQL Database (to store your data)
Authentication (to authenticate users)
Storage (to store files)
Functions (to write serverless functions)
Machine Learning
and many more

Is it possible to perform database operation on locally stored DB through javascript (WebSQL or Indexeddb)

i am developing offline web app for android platform and i want to use offline database for it. Is there any way to connect to locally stored database through javascript. like
var db = opendatabase("file:///android_asset/myLocalDb.db");
var Records = db.executeSQL("Select * form myTable");
echo Records;
I use PouchDB. It is a NoSQL type database backend, but has great cross platform support so you don't have to worry about the underlying storage mechanism across browsers. If you have flexibility on the database type, it may be the easiest solution.
Are you making a Cordova app, or in-browser hybrid offline but specifically targeting Android? You can use SQL Lite with Cordova and bubble up from your Javascript to access the db. Check out: https://stackoverflow.com/a/26609184/1011603
Yes, it is possible to package your application and data file as web app by packaging appcache. Since browser manage data storage for database (indexeddb or websql), it is not possible to specify them by your file name.

Accessing Websql database with Qt

I'm making a web app and I need to store some data into a database that can also be accessed with Qt. What I need is to insert values from the web app and the app created with Qt.
I'm storing the info that comes from the web app in a WebSql database with javascript in Linux Mint.
I wan't to know if it is possible to access that database file with Qt.
Are there a better alternative to do this without a server-side languages?
Yes you can access the websql database with Qt. The websql database is just a sqlite database so there is no problem accessing it with Qt.
The tricks are finding the location and name of the file. In Chrome on my Mac, for example, the database is at
~/Library/Application Support/Google/Chrome/Default/Databases/mysite/1
there is a master database of the other databases at
~/Library/Application Support/Google/Chrome/Default/Databases/Databases.db
It is also sqlite and you can read it to find the other databases.

Send data to the server whithout affecting the UI cordova

I am working on a cordova project using angular JS. In our app we will store the transactions in the SQLite DB when the app is offline and will send the data to the server once the device came online. While sending the data to the server, the user should able to access the UI. That means the data should be send in a separate thread. Is it possible to do in Javascript/angular JS? If so how to do it?

Javascript that communicates with a Hosted API?

Basically I'm developing .NET API that allows a certain Javascript to access a Database through it. The database contains User Information and the API is the mediator between the client (running the javascript on their websites) and the database. The javascript simply gets the data from the DB and displays them.
My problem is, where do I host my API so that the client Javascripts can access it? What is this system called? I'm using Microsoft Azure SQL Databases to store the user information. How do I access my C# API from the client's javascripts? Do I need to host my API on Azure's API Hosting service? Very confused.
1) Client adds the Javascript and a HTML div to their website
2) The Javascript should access the API
3) API accesses the Database and gets the Data (Which is completed and it works)
4) Send the Data to the client and the javascript populates it
I just need to figure out how to make a connection between the API and the javascript on the client's website
Do I need to use THIS?
I would use ASP.NET Web.Api. It allows you to build a REST endpoint in C# that you can host on the Azure platform as well. You will be able to host it using the web sites features of Azure. Even though you want to build an API not a web site hosting it in a web site container will give you what you need:
Easy hosting solutions
Web endpoints for your client JavaScript to consume
C#.NET
Web endpoints close to your database. (Host them in the same data center)
Scalability
Monitoring
Ability to create a web site at the same address if you need to.
I haven't used Azure api management so I can't comment on that, but you will be able to get an ASP.NET Web.Api site up very quickly.

Categories