HTML/Javascript - Can I access a user's local SQL server (with their permission)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
HTML/Javascript - Can I access a user's local SQL server (with their permission)
This is an odd one, I know ...
My company uses a private database-driven web site to manage most of our administrative duties, but due to the huge amount of data available on one screen, it is becoming unmanageable for some off-site staff on slow Internet connections.
We use PHP to generate the pages, but that's server-side scripting, and we need to avoid pulling this information from the server.
One solution we have discussed is for the users of the site to install MySQL on their own machines, and keep a cached copy of that table locally (that table only updates about once a month, but it's HUGE).
So, what I'm asking is ...
Can my web page pull data off the viewer's SQL server, using client-side processing (Javascript, or something like that)?
I have looked into other options, like training the users to download this table as a text file, and typing in a ID number for the entry they need ... but that idea went down like a lead balloon.
As far as I am aware JavaScript doesn't have any SQL support. It does have support for reading files so maybe you could write a script to read the table information from a local file. You problem is then to get the database into a file format, which you suggested that you have already considered. However rather than one file which may be slow you may want to consider breaking it down into smaller files, with the name indicating the ID range.
Actually, that's not such a bad idea ... I could convert the table into a file or series of files, and have people download new copies when their version becomes out of date. I'll look into that/ Thanks for the advise
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
I understand that the speed becomes a problem if there is a slow connection between the server and the client?
If you are able to install MySQL + database on the client's machines, can't you install the entire database + application + web server? The database will be by far the largest. Is I take it, copying once in a while is an option.
I have a large application running on LAMP. When I travel and I want to develop the application I simple copy the database and scripts, everything else I have running, and it is like I am at home.
If the scripts were written to connect to the database on 'localhost' you'd be fine, otherwise the developers built in a configuration option to point to localhost as this is what you will be using on your client.
Copying tables or databases is a breeze with MySQL. You could even think of more sophisticated synchronization schemes.
"If you are able to install MySQL + database on the client's machines..."
Yes, that was one thing I thought very carefully about ... but ruled that out as an option because every other table changes very rapidly (and the remote users are constantly creating new data), and we don't want to have synchronisation problems. Also, the web application itself is undergoing constant upgrades (I am employed full time to provide 'continual improvement'), and the remote users are not the sort of people who would be able to upload updates to a web server, and considering the distances between us, they don't bring they're machines into the main office very often *maybe once every 6 months).
As for the suggestion of storing the file locally, I have tried that out, and so far, the browser is either loading the file as a blank, or saying the file does not exist. Since we use Windows, Mac, and Linux (hosting on Linux), ActiveX is not an option. I found this link ... http://snipplr.com/view/4021/read-lo...mlhttprequest/ but it's saying the file is not found ... I tried placing the file I want in my home folder, and also in the root folder of the file system, and another copy in the /var/www folder, and it didn't find any of them.
Some web sites have suggested using a Java applet as a download assistant, but I haven't seen any examples of this as yet (I'm not really a Java / Javascript expert).
Sorry my mistake, the reading of files within JavaScript is limited for security reasons. My thoughts are you could look at another scripting language, which would complicate the install issue or, maybe the php.js project
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.