I'm trying to create a real time web application with NodeJS with an MVC layout using the Express framework and MySQL as my back end data store.
The problem that I've run into is that I can't find any good examples or tutorials on how to use Socket.io (or any other web socket platform to pass information in real time from the database to the web application. The specific problem is getting any new update to MySQL on a specific table to pass that information to, so that if new information is added to the database by a second client connection it will update on the first client connection as soon as the information is added.
Does anyone have any ideas on how to get socket.io(or another websocket connection protocol) and mysql to work together to achieve this? Any code example's or pointing me to some websites that have documentation on this topic would be appreciated.
Thank you!
Related
I've recently begun developing with NodeJS and ElectronJS to create some pretty nifty cross platform software. I want to take it a step further and integrate some database functionality.
While I'm aware that there are mysql packages available to install, I cringe at the idea that anybody can just unpack my asar.app file and see all of the connection details, including username, password, database name, table name, and other sensitive content that you really don't want to expose to people clever enough to break into your app's source code.
I've tried searching extensively on solutions to this problem, which I was surprised to find very little about. How do WhatsApp and Slack secure connections to their database if they were also built with ElectronJS?
Any and all resources are greatly appreciated. I basically want to be able to connect to a production server SQL database in an ElectronJS app without leaving some security backdoor to anybody who cracks the ASAR file.
Thank you!!
For this scenario, I suggest you to use a RESTful web service architecture. Basically you need 3 component, RESTful web back end, client application(your electron) and the database service( see the following image ; source:phppot.com) .For this I suggest you to use nodeJS backend and create a webservice using expressJS . You can define Restful (GET, POST,UPDATE, DELETE) API for each services.
For ex: To get some data from your db, you can send a GET request to the following path <yourdomain>:<port>/api/v1/getyoursomthin using your electron app. Your express app process the request and get the relevant data from the data from the database (Tutorial). So your app can get the respond from the server and display to the user. I will add link to some tutorials. You can find and learn more by google :)
Web: Build a simple app using Node JS and MySQL.
Express.js Tutorial: Build RESTful APIs with Node and Express
( source:phppot.com)
I just started learning Node.js and want to handle a session using MySQL database. I want to do it without express or any kind of framework. I searched through google but couldn't manage to get an answer to my query. My present condition of this task is: I designed my .html files, created HTTP server using http module, managed to connect the database, and now desperately want to create a session (when a user logged in) and destroy it.
I am working on an app in visual c++ which requires data to be accessed from a database which can be edited so that every time there is a modification to the data I do not have to resend the app as it will automatically update, it is also required that this is a desktop app.
I am currently using MySql however for this to run constantly I will be needing a server which for a single simple app wont really be worth purchasing, so I started thinking of alternative methods and thought to myself there must be some method of reading directly from a website or online database, am I correct in thinking this? If so could someone please explain how I would achieve this?
Also, I have purchased phpmyadmin in the past so if there is any way I could connect my visual c++ app to a database from this then that would be great.
EDIT: Note, this app relies almost entirely on the database as it is just 3 combo box's and one text field all of that values for which come from the database.
The following response is assuming that by online you mean on the web.
You cannot exactly 'connect' to an online database with C++ (or anything outside of that server hosting the database).
What I would do is create some PHP API's that you can POST to with libcurl via C++. You can both send and receive data this way.
Hey i need some help here, i am developing a vb.net desktop application using visual Studio 2010 and mysql v5.5 whose database will be located in a main server hence the applications will have to communicate with the the database to get/post information.
My problem however is that, i want my applications to have a real time update of the database content such that if user1 updates the database, it immediately reflects that in user2's application. I have read articles that recommend use of triggers and Stored Procedures in mysql syntax to do this but i have no idea how this will work.
I have a table called 'Store' , when a user enters an item in table store, i'd like the application to know it and update the Item and its contents in a listbox or datagrid.
How do i capture these events in my vb.net code?
I hope i am clear enough, if not please ask. All your suggestions will be highly appreciated!
I think the easiest way to solve the problem would be to periodically get the records from the server and update the local list appropriately. On your client application you could store the last time the list was updated, and send that as a parameter when you do the get and get all the items that were created after that time (that way you only get new items).
Another possible solution would be to have a client register with the server application (so the server keeps track of all the clients) and when you create a new record you send that new record to all the clients, which would be listening for that event.
It's sort of hard to say what the 'best' approach is in your situation. How is your code designed (what's the architecture)? Are connections between the client and server applications persistent? Is there a server application that your client application talks to or is each client directly talking to the database?
I am really confused on how to get data in and out of an android app from the internet.
I imagined that I would store information in the mysql db on the server I already have set up. But from what I have read, I would need some type of in-between web service to make queries with data sent from the app.
Can anybody toss me some tips on how to get something like this started.
Or, if you know of a better way, let me know about it.
This question has been asked several times, for example here: How to get from a MySql server to an Android app?.
Bottom line - you don't connect directly. You have something on your server (like RESTful) that you connect with via HTTP.
Try this method out. I will be using this method for the current project i am working on.
You basically create a php script on a server and use http posts to send the data to the script, read the tutorial linked below for better explanation.
mysql/android tutorial