Best practice for retrieving data? SQL Database vs HTML parsing - mysql

I'm developing an app that displays a list of products that are in stock from various electronics websites. I have two methods in mind for accomplishing this task.
Create a C# application that parses the html from the various websites and updates a SQL table, use a php script to get data from the SQL
table, display it in JSON format, and parse the JSON with the iPhone
Use the iPhone to parse html from each website, eliminating the need for a server and SQL database
I don't know all the pros and cons for each method, but I do know that hosting a web server with a SQL database costs money. However, using the iPhone to parse html from over 40 websites could be very slow, and use a lot of data.
Which one is the best method for creating an app like this? Am I even on the right track?
Thanks,
Miles

I would prefer the web service approach in which I would parse it on my own server and then serve a JSON representation to iPhone.
Why?
Because when something changes on the html you won't need to wait for Apple to confirm your app change, and user will not need to update his app.

Your First Option is much prefered with little change. You Don't Need C# TO parse the HTML as PHP has all options you need. IT can save data in Database and similary can output in your desired format.
As per the Cost, using Iphone may cost you more with data usage(Operator service Charges) as compare to web server hosting with PHP & mysql. Further you can have already optimised facilities of HTML parsing in own server with tendency to meet all complexities served on WEB.

Related

how do i store and retrieve form data from a wesbite

this is probably something i could have googled; however i thought id start getting more active on chat forums so basically...
I'm almost done with making a family members business website, on the website is an enquiry form; i want to know how i go making that form store the data its given and how i would then retrieve that data?
still doing final touches to the design then im going to start learning the process of deploying it live which is why im posting here to see how to go about it.
It is very vast question, You will need an API to pass the data from Forms to API Server and a Database, that will store the data. It is also called client-server architecture.
Web Forms -> API Server -> Database
You can use either node express, java, python or any language to create API.
You can install the database on the server where you will run the API or you can use any from the cloud like AWS or Heroku, that way you will skip some setups and it will be ready to be used directly in the API.
To store data from an HTML form, you will need a server-side language and a database to save the data to. Some popular options for the server-side language include PHP, Java, and Python.
Once you have chosen a server-side language, you can use it to write code that will process the form data when the form is submitted. This typically involves connecting to a database, creating a table to store the data in, and then inserting the form data into the table.
To retrieve the data from the database, you will need to use a SQL query to fetch the data from the table. You can then use the server-side language to display the data on the website as needed.
It's a good idea to also consider security when handling form data. Make sure to validate and sanitize the form data to prevent any potential security vulnerabilities.

MySql Workbench and Html Sublimetext 3

I have been writing SQL queries for a while now, but brand new to HTML.
I have been using Sublime text to code HTML and using Mysql - Workbench to code databases etc on local server.
I'm wondering..
How do I code HTML to return SQL queries onto a console (Google Chrome)? and connect the two together
I have searched all over google and You Tube, only thing I can find is something to do with PHP.. not sure what how it works, but don't think that is something I need.
All I want to do is create a text box inside HTML and input id value as an example 10 and return the id number along with the whole row from the database.
Using this query: select * from tableName where id = 10;
HTML is a document formatting language. While it supports JavaScript, said JavaScript is sandboxed in the browser: It cannot easily access files and the like even when that other stuff is running on the same computer as the browser. The main reason here is security. Imagine every web page on the Internet could look at every file on your disk, copy them or save new files on your disk or modify them.
So what you need is a "server software" of some kind. This software talks to the browser. It sends it all the HTML that the browser requests. The HTML can then ask for more (for example using JavaScript and AJAX). These requests go to the server which parses the parameters, collects the data (only the server talks to the database) and sends results back.
This is a pretty complicated and involved process. For this reason, everyone uses a framework to do it. The framework handles all the ugly stuff like converting query results from the database into the types and objects of the programming language and then again to HTML code which looks good.
Since you don't know any programming languages, yet, I suggest you start with Python. A good web framework for Python is called "Django". Django also contains modules to talk to databases. It also has many "widgets" like tables that display query results.
Google for "python django mysql" which should give you plenty of examples.

Creating a REST API for static hosting

I know this sounds crazy, but I had a thought and I was willing to try it out. I use GitLab pages for all my online projects, but a lot of them are ASP.NET MVC, which is an issue as I don't think you can run ASP.NET MVC sites on GitLab pages. I then thought, what if I make a site using something like angular or node.js, and have a central API for all my web projects? I thought that was a great idea, until I realized I couldn't use a database either. I guess what I'm asking is, would it be possible to create a REST API that uses JSON files for storage and node.js as the request pages, to create an API without a database?
Of course.
If you think about a database from the perspective of your application code, it is basically just a place to store and retrieve data.
Imagine the database library you are using has two simple methods, store and retrieve. In your application code, you could write db.store('here is the item') and the later on, db.retrieve().
However, those store and retrieve methods could be implemented in many different ways to provide the same effective behavior from the perspective of your application. Some examples:
Send/query the data to/from an external data store, such as PostgreSQL
Write it to a file on disk and read it back later
Store the data in memory
Make HTTP requests to an external system to store the data
Some of these options will be more or less appropriate depending on your exact requirements, however, the general idea is that given a database API, you could implement the exact same method signatures with a completely different approach.

Is it possible to write mysql queries in Angular.JS?

Im new to Angular.JS and just wondering if it is possible to write mysql queries in angularjs?
I would like this as I am trying to create a messaging system in which I query the database and get the information live to the webpage.
Any help is appreciated, hope the question is reasonable. Gab
That is not advisable (if possible at all) as it would defeat the purpose of Angular.
You should consume data by targeting a RESTful api/service exposed by the server. The service would handle the DB access for you and provide the data to Angular using a more portable format (e.g. JSON or XML)
Some of the basics of linking Angular and REST are described here
There are related questions on SO about exposing your particular DB flavor using REST here.
This can only be a starting point but it should give you some ideas. I will try to amend this with more info as I come across it.

iOS and SQL xml report

I know that there's a lot of posts about that, but i can't find any one that suit my needs.
Here we go: I am developing (newbie dev, of course) an iOS app that is suppose to populate an UITableView with the acquired data from a xml report from a server (mysql and php).
The point is I was able to manually generate the sql report on the server (actually is a wordpress plugin that manually generate and save the report inside a folder on the server) and made the app download it by pointing to the right location of the file (very basic i Know) but is there an easy way of making my app send a request to the server to automatically generate and download the xml?
All the data i must use is inside a database on the server. The parse of the xml is not that difficult and I can handle it. My real problem is allowing the app sending those requests to the server.
Please note that i have no experience in PHP or SQL and have poor knowledgement on that tools so that is what i haven't found any post that suits me as all of them talks in a advanced SQL and PHP language.
All help is appreciated.
Thanks in advance folks!
You'll want to make an NSUrlRequest against a php script on your web server that runs the query and returns the XML as the output. See this link from the Apple guide to get you started: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
The question is too general to give more specific advice than that you should take a look at the Cocoa URL loading system, or alternatively another networking library such AFNetworking.