Using Javascript to open a local MS Access file - javascript

I am trying to build a web application to replace the functionality of an older desktop economics program. That program is essentially a calculation engine built on top of a Microsoft access database. The inputs and results are all stored on a series of tables. To offer compatibility to the legacy users, I want to have the ability for users to connect to their older, local access databases and upload them into the web app.
The approach I was contemplating was to have a page that allowed the user to select the database they wanted from their local machine and then have the schema and the data for each table sent to the web application. I don't really want to upload the whole file -- I just want to extract the relevant data.
I have done some research and I have looked into the HTML File API. One shortcoming is that the API does not expose the file path of a selected file so there does not seem to be a way to pass that to the connection string necessary to connect to the database using ODBC or ADO.
In summary my basic question is: How can I get the contents of a user's local database into a web application only using the browser?

You will have to upload the whole file to the server first. You can do your manipulations on the server to save only the relevant part and delete the rest... For security reasons Javascript is not able to read file's content from the local user's machine.
A suggestion - you can upload the file to server, read and print the relevant data as JSON or XML format, then delete the file and use all the data in your ajax response on the client's browser.

Related

How do you store large amount of text for a webpage

I have a book in docx format (about 25,000 words) and I want to display about 400 words at a time on my webpage. In Python, I have an algorithm that separates the text into pages and stores that in a dictionary; however, the frontend uses JavaScript.
I have tried to export the Python output as a txt/json file, but it seems that JavaScript doesn't allow automatic file uploading and instead requires the user to upload the documents which won't work for my situation. So, do I have to store all of the text (25,000 words) in an html document and then run a JavaScript version of the Python algorithm on that and then save it into local storage or some JavaScript container?
I want to avoid using a web host for this since I don't think it is necessary.
You would typically build a web API for retrieving data, you would use a database/flat file store for storing the data and the frontend would form the presentation part. Depending on your usecase and if you are not familiar with databases, I'd suggest as a first step you could just store the pages as simple files on the backend.
So, your data i.e. the pages of the book would be stored in text or JSON. Your backend service(which can be in Python or JS or pretty much any other popular language) would have APIs that facilitate retrieving these webpages and your frontend(HTML + CSS + JS) would be responsible for capturing user input and requesting data from the backend service.
So, the flow for reading a page becomes -
The user opens the frontend, which would comprise of HTML + CSS + JS
The frontend retrieves a page from the backend API
The backend API reads the page on your machine and returns it
If the only reason you don't want to use a backend or host is because it is not required, in my opinion what you are trying to build would typically require a backend service since you'd generally want to have control of data so that you can have other mechanisms for auth, updates to the pages, etc.

Is it possible to load structure and data to angular-storage(or another storage) from a SQLite file from server?

I think what I'm trying to do is very simple, but I'm having a really bad time trying to search this on the internet. I have this populated sqlite db file in my server, and I want to import its structure and data into my web application. This file is generated from another server-side app in a path which is accessible to the web application.
Your web application should access the database with its proper adapter (depending on the language and the framework) and then provide the data to the front-end as a set of services. It strongly depends on the amount of data and its variability whther you want to serialize all the data at application load time, or just to provide data access using several endpoints (by using the sqlite database as the repository for your application models).
It's not much different from a normal web application, provided you don't want to write on the sqlite database and so consider all your models read-only.

Run a query on a local SQLite file, from JavaScript

I want to execute queries against a local SQLite file, from JavaScript. How can this be done?
By local, I mean a .sqlite file on the user's computer. I do not need storage for an application, so suggestions about WebSQL are not helpful.
The use-case is, I have many local SQLite files that I use as a database for other applications. I am trying to build a Chrome Extension that lets me query the SQLite files so I can see data contents without having to use my SQLlite workbench app, which sucks.
An extension would not be able to do that. While you can "upload" a file to an extension, it would not retain access to the file on disk; it would be just a snapshot at the moment of an upload.
An app, however, can. With chrome.filesystem API, you can request read or read/write access to a file, and retain the resulting entry to query it again later without dialogs to the user.
Of course, it's up to your JS code to actually read the database. There is no API for that, you need to use a library.

Updating XML file on server

I have an Eclipse project being run locally from my machine through Tomcat. The project is a web application with patients, HCPs, and administrators able to log in to do various tasks. One of these tasks is to run a group report on patients based on certain search criteria. After a group report is run, there should be an option to view the group report as in XML format.
The way that I have structured my project is I have created a groupReport.xml file locally. Once this file was created, I committed it so that when I run the project on a Tomcat server, I can manually point my browser to the website address of where the XML file is stored on my server (localhost:8080/project/groupReport.xml for example).
Each time that a group report is run, I have a java class that rewrites the groupReport.xml to reflect the new changes. This java class uses a FileWriter that writes it to the local path on my hard drive. The problem with this is that navigating to localhost:8080/project/groupReport.xml will only display the XML information for the group report that was first committed before the server was started. It does not reflect any changes to the XML that has been rewritten locally.
I have tried to use relative pathnames to have FileWriter write to the XML file being stored on the server side, but could not achieve the results I was looking for. Is there any way for the XML on my server (localhost:8080/project/groupReport.xml) to be rewritten any time the locally stored XML file is rewritten?
I do not know any PHP or Ajax, so if there's a similar solution using just Java and Javascript, that would be preferable.

Access read-only online SQLite from javascript

I want to develop an web application that can be served without web server. I mean, via file:///... in a web browser. The application will use HTML5 and Javascript. Also , I would like to add a SQLite with the data to be presented in the application. The database will be static so a read-only access is enough. I don't want a HTML5 local storage solution because the SQLite database is already created and must be load from "server".
I don't find any solution. A pseudocode example may be the following one:
var db = load ("file:///path/to/my/database/file.sqlite");
db.execute ("SELECT * FROM DATABASE");
// Show items
load from the system files, I think this is not posible due to security reasons.
chek this online tool to manage local data storage at: http://wdbengine.sourceforge.net

Categories

Resources