MySql Workbench and Html Sublimetext 3 - html

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.

Related

How to create / integrate database on TYPO3

Good Morning,
as from the title, i'd like to create a proprietary database to be integrate in a Typo3 website.
I'd like to receive some advise on which is the best solution:
- is it possible to create tables directly from Typo3?
- is it better creating a database, for example with MySQL and then integrate
it?
In the second case, how coud that be done?
are there other options?
I hope this is not an already answered topic, in case, please send me to it ( i could not find so much information.
Thanks in advance.
If I understand your question correctly, you want to add a custom Extension to TYPO3, containing custom tables. From a content side, this is perceived as a "database", right?
TYPO3 has a framework for that called Extbase. You can "kickstart" a TYPO3 extension with the "Extension Builder" https://typo3.org/extensions/repository/view/extension_builder by entering the "Model" (the data structure) via GUI and then you get all tables etc. automatically set up.
After that (aside from general TYPO3 knowledge), there is some coding involved. In theory, it's possible to make a "round trip" back to the extension builder from the code, but I've never done that.
You need to know / learn the specificities of extbase / php, which is is based on some "convention over configuration" rules and has some additional tweaks to plain PHP (functional comments). Here's a great resource: http://www.extbase-book.org/.
With that, you have great flexibility and powerful tooling to build almost anything inside TYPO3.
From a TYPO3 view it is best if you are able to hold your data in the TYPO3 database. You need to create an extension to handle your data. In TYPO3 an extension can define it's own tables and with updates of the extension updates in the datastructure are handled automatically.
Since version 8 there is a new layer (doctrine) and so it is possible to define further databases for individual tables. With some restrictions you are able to even use different database (-systems) for different tables.
Anyway you could program your own database interface to get and store your data independent from any TYPO3 restrictions, but then you need to handle everything on your own.
Using the TYPO3 core API will help you in multiple ways to handle your data without programming everything anew.
Especially if you use extbase (and the EXT:extensionbuilder) you will get a complete BE data handling, FE-Plugins with Fluid templates to present your data, even data management from the FE could be generated for you just by defining the datastructure. Of course versioning, workspace and timed visibility support are also available if you use TYPO3 structures which includes some (mostly invisible) fields aside from uid, hidden, deleted.

Best practice for retrieving data? SQL Database vs HTML parsing

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.

Extensible DB editor

I'm using MySQL.
In my DB there are several tables, containing fields with data, serialized in custom binary format. (Actually, these fields contain lists of fixed-format records, like a "sub-table".)
I need a tool to be able to edit those fields by hand while my own fancy data administration UI is still in development.
I wonder, if there is a DB viewer/editor (like PHPMyAdmin or Sequel Pro or whatever) which I would be able to easily extend to deserialize that extra data?
Note that the [de]serialization library is in plain C and I do not want to spend much time rewriting it in another language. (I would better spend that time on that data administration UI.)
Any clues?
P.S. I need the editor to work on OS X or Ubuntu (Wine is fine) or be web-based.
Sequel Pro is open source, so you can probably get the sources and hack your code in there.
Get it here.
This is a Java app http://www.isqlviewer.com/ . You could load your C library in that using JNI. I've used iSQLviewer a lot with various databases and the download comes with code, but I can't say I've ever looked at the code!

Mysql adapter for Zend_Translate

I'm currently in the planning phase of a rather large project that I'll develop in the Zend Framework. One of the problems I'm facing is that the customers will want to translate not only the content but also the interface. I'm currently using gettext and poedit to manage my language files but this is not an option for the customer as they, for one, wont have FTP access to the site.
Hence, I'm thinking of a mysql back end with an interface in the front end for the customer to manage his own translations of the interface. There is however still no mysql adapater for Zend_Translate.
So, does anybody now of an adapter script for Zend_Translate so it can work with a mysql table? Or any arguments against using mysql and possible other solutions for this problem?
You could solve this problem on different ways:
Extend Zend_Translate_Adapter to create your own. All new adapters are only responsible from getting the translations out from the source. That is, you would need only to fetch the translations from the database. Look at other adapters and see how they are implemented.
Fetch the data from the database and pass it to Zend_Translate_Adapter_Array
Use Zend_Translate_Adapter_Csv or Ini. As there would be more reading the writing on the translations, this solution would cut down the number of queries to the database. When the client adds a new language or changes an existing one, simply write it to a file, not the database.
If you decide to go with the database adapter, maybe you could "tag" somehow the translations, so that on the home page you fetch only the translations for the home page, on the contact page only the translations for the contact page...
HTH!
Default Zend adapters handle caching well, so I'd stick to them, unless you really need database.
Instead storing the translation data in the database, you may directly operate on the translation files (e.g. po templates). This would be the best choice if you just needed to add (append to file) new translation strings.
You may use Zend_Translate's option to log untranslated messages (to file or any log adapter, including database),
and then handle the logs, or even create listener translating the saved strings.
Here's how: http://cloetensbrecht.be/zend_translate_mysql.html

Can I run an HTTP GET directly in SQL under MySQL?

I'd love to do this:
UPDATE table SET blobCol = HTTPGET(urlCol) WHERE whatever LIMIT n;
Is there code available to do this? I known this should be possible as the MySQL Docs include an example of adding a function that does a DNS lookup.
MySQL / windows / Preferably without having to compile stuff, but I can.
(If you haven't heard of anything like this but you would expect that you would have if it did exist, A "proly not" would be nice.)
EDIT: I known this would open a whole can-o-worms re security, however in my cases, the only access to the DB is via the mysql console app. Its is not a world accessible system. It is not a web back end. It is only a local data logging system
No, thank goodness — it would be a security horror. Every SQL injection hole in an application could be leveraged to start spamming connections to attack other sites.
You could, I suppose, write it in C and compile it as a UDF. But I don't think it really gets you anything in comparison to just SELECTing in your application layer and looping over the results doing HTTP GETs and UPDATEing. If we're talking about making HTTP connections, the extra efficiency of doing it in the database layer will be completely dwarfed by the network delays anyway.
I don't know of any function like that as part of MySQL.
Are you just trying to retreive HTML data from many URLs?
An alternative solution might be to use Google spreadsheet's importHtml function.
Google Spreadsheets Lets You Import Online Data
Proly not. Best practises in a web-enviroment is to have database-servers isolated from the outside, both ways, meaning that the db-server wouldn't be allowed to fetch stuff from the internet.
Proly not.
If you're absolutely determined to get web content from within an SQL environ, there are as far as I know two possibilities:
Write a custom MySQL UDF in C (as bobince mentioned). The could potentially be a huge job, depending on your experience of C, how much security you want, how complete you want the UDF to be: eg. Just GET requests? How about POST? HEAD? etc.
Use a different database which can do this. If you're happy with SQL you could probably do this with PostgreSQL and one of the snap-in languages such as Python or PHP.
If you're not too fussed about sticking with SQL you could use something like eXist. You can do this type of thing relatively easily with XQuery, and would benefit from being able to easily modify the results to fit your schema (rather than just lumping it into a blob field) or store the page "as is" as an xhtml doc in the DB.
Then you can run queries very quickly across all documents to, for instance, get all the links or quotes or whatever. You could even apply XSL to such a result with very little extra work. Great if you're storing the pages for reference and want to adapt the results into a personal "intranet"-style app.
Also since eXist is document-centric it has lots of great methods for fuzzy-text searching, near-word searching, and has a great full-text index (much better than MySQL's). Perfect if you're after doing some data-mining on the content, eg: find me all documents where a word like "burger" within 50 words of "hotdog" where the word isn't in a UL list. Try doing that native in MySQL!
As an aside, and with no malice intended; I often wonder why eXist is over-looked when people build CMSs. Its a database that can store content in its native format (XML, or its subset (x)HTML), query it with ease in its native format, and can translate it from its native format with a powerful templating language which looks and acts like its native format. Sometimes SQL is just plain wrong for the job!
Sorry. Didn't mean to waffle! :-$