I am making small standalone html 5 application using deskshell, I want to use MySQL database. How can I connect from JavaScript to MySQL without using PHP or server side language?
using html5 standalone app using deskshell to connect to mysql
593 Views Asked by ronvinet At
1
There are 1 best solutions below
Related Questions in MYSQL
- Azure IOT Hub Rest API Unauthorized
- Stream Analytics: Dynamic output path based on message payload
- Iot Hub connection string not working in azure-iot-sdk-c samples
- Azure,Android,Raspberry pi
- Any APIs to get list of consumer groups created in Azure IotHub?
- In queue message count in service bus
- Uploading an image with Azure IoT SDK for Python
- Azure IoT Python SDK how to set content type on uploaded images
- Bi-Directional Communication via IoTHub/Xamarin App/ESP8266
- How to delete all devices from Azure IoT Hub using C#?
Related Questions in HTML
- Azure IOT Hub Rest API Unauthorized
- Stream Analytics: Dynamic output path based on message payload
- Iot Hub connection string not working in azure-iot-sdk-c samples
- Azure,Android,Raspberry pi
- Any APIs to get list of consumer groups created in Azure IotHub?
- In queue message count in service bus
- Uploading an image with Azure IoT SDK for Python
- Azure IoT Python SDK how to set content type on uploaded images
- Bi-Directional Communication via IoTHub/Xamarin App/ESP8266
- How to delete all devices from Azure IoT Hub using C#?
Related Questions in NODE.JS
- Azure IOT Hub Rest API Unauthorized
- Stream Analytics: Dynamic output path based on message payload
- Iot Hub connection string not working in azure-iot-sdk-c samples
- Azure,Android,Raspberry pi
- Any APIs to get list of consumer groups created in Azure IotHub?
- In queue message count in service bus
- Uploading an image with Azure IoT SDK for Python
- Azure IoT Python SDK how to set content type on uploaded images
- Bi-Directional Communication via IoTHub/Xamarin App/ESP8266
- How to delete all devices from Azure IoT Hub using C#?
Related Questions in APPJS
- Azure IOT Hub Rest API Unauthorized
- Stream Analytics: Dynamic output path based on message payload
- Iot Hub connection string not working in azure-iot-sdk-c samples
- Azure,Android,Raspberry pi
- Any APIs to get list of consumer groups created in Azure IotHub?
- In queue message count in service bus
- Uploading an image with Azure IoT SDK for Python
- Azure IoT Python SDK how to set content type on uploaded images
- Bi-Directional Communication via IoTHub/Xamarin App/ESP8266
- How to delete all devices from Azure IoT Hub using C#?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
This is definitely possible using deskshell. It can be a little confusing as to what is the server and what is the client etc. Generally it is much simpler than you at first think.
I suggest the following approach. Deskshell uses an unmodified nodejs binary. So to make life simpler begin by first installing node (so it sets up everything like paths etc for you). Then use npm - the node package manager to install a module that will allow you to connect to mysql. You can go to the npm website and search for mysql. When you find a package you can npm install packagename. You can remove then afterwards with npm remove packagename. (Check website for exact syntax).
So using this approach and copying and modifying the examples from the modules homepage you should be able to get nodejs to connect to mysql and run some queries.
The next step is then to add this "database ability" to your application. Here you should realise you have 2 javascript engines running. You have one "sandboxed" v8 js engine running in the chrome browser and you then have a second "unsandboxed" v8 nodejs that will run your app.js file. I find the simplest and most pleasing way to connect the two is to use a websocket to send messages from one v8 to the other. Then you can decide the level of abstraction to write your little api at. So you could write all logic in the browser scripts, send the sql ocer the socket, nodejs app.js script then recieves message, queries mysql and returns results as json. An alternative would be you ask the api for 20 user objects and it turns the request into sql and executes it for you and returns it to the browser.
You will need to copy the node_modules/packagename folder to your application directory as node_modules/packagename. In addition you may need to change your deskshell code from require ("packagename") to be require ("./path/to/package/folder")
I would suggest you look at using sqlite3 as your database engine if a separate server is not used for your application. This is because sqlite3 is a file based in process database so you do not have to run a server process on the end users machine. However if you are connecting to an existing server database then mysql is the better option.