LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   HTML/Javascript - Can I access a user's local SQL server (with their permission) (https://www.linuxquestions.org/questions/programming-9/html-javascript-can-i-access-a-users-local-sql-server-with-their-permission-753030/)

fcdev 09-06-2009 02:41 AM

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.

Any suggestions would be greatly appreciated.

- Stephen Fraser

graemef 09-06-2009 04:11 AM

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.

fcdev 09-06-2009 01:45 PM

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 :)

jlinkels 09-06-2009 07:02 PM

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.

jlinkels

fcdev 09-06-2009 09:05 PM

"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).

graemef 09-07-2009 03:08 AM

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


All times are GMT -5. The time now is 02:21 AM.