Html5 - Javascript - sqlite for intranet? - javascript

I need some database functionality for our intranet at work, but I am severely limited in my options. My only scripting tools are JavaScript/JQuery.
I was wondering if it would be possible to use SQLite with html5 and JS/JQ?
Thanks for all the pointers in the right direction!
Desired usage:
I wish to port in a large excel sheet in the db file, and run queries and return row results in the intranet page.

Yes it's possible, there are some libraries on the web. For example, the library sql.js is a port of SQLite to Javascript.

There are many options to solve this problem:
There are some packages, which can read data from XLSX file directly, for example: js-xlsx library, where you can retrieve data directly from Excel table (so, you do not need to use SQLite). It takes some time to read whole Excel, but you can keep your XLSX alive.
You can install simple node server for your intranet with SQLite package. This is a fastest way, because the client version of SQL.js loads whole file with database, which can be much bigger than original XLSX file.

Related

Import data from CSV to a table in Oracle with NodeJs

I have a doubt.
I would like to know if it is possible to insert data (100K data) that I have in a CSV file, directly to a table in Oracle, using NodeJs.
I have looked for several ways, but I have not found a solution, only the use of external tables but the problem is that I must save the CSV file in a specific directory.
I don't know NodeJs, sorry.
But, from Oracle's side of story, you could use an external table (as you've already mentioned). If that "specific directory" is located on the database server, great! as you'd have to create a directory (an Oracle object) which points to that filesystem directory (and grant read and possibly write privileges to user which will be using that directory).
If it isn't located on the server, you'd still be able to do it by using UNC (universal naming convention).
Another option is SQL*Loader, a command-line tool which can be used on your local PC (you don't have to have access to and "directory" which is related to the database server in any way). You do have to have SQL*Loader installed, of course. It comes with every Oracle database; if you don't have it installed on that PC, you'd install Oracle Client.
There are various Node.js modules to read CSV files. Use one, and then when you have the data in Node.js, you can use node-oracledb's executeMany() to insert multiple rows at once into the DB, see the node-oracledb documentation Batch Statement Execution and Bulk Loading.
However, I would probably go with the earlier solution and use SQL*Loader, see https://blogs.oracle.com/opal/oracle-instant-client-122-now-has-sqlloader-and-data-pump

Excel Module For NodeJS

I want to create .xls .xlsx file from NodeJS but i can't find any stable module for do that.
Is there any stable nodejs module for generating simple excel pages ?
The Excel format is published by Microsoft as an open specification. You can get the spec here in a nicely formatted, intimidating 1200 page PDF.
I've used Microsoft spec documents before to figure out how to implement partial (incomplete) systems that just serve my specific use cases. In other words, if you can figure out the exact bits you need (i.e. just convert a 2d array into some excel rows), then you can often ignore rest of the spec as it doesn't apply to you.
I've also found that looking at solutions written in other languages has helped me - for example, here's a project that uses c#.
Depending on whats available on your backend system, you could spawn a child process that handles the conversion.
Or, you could offload the whole thing to a web service. Google Documents List API allows you to store and manipulate files Google Docs, and then with Google Spreadsheets API you can read and modify the data in Google Spreadsheets.
I realize none of this really addresses your question of the availability of a library, but might give you a new way of solving the problem.
Did you tried the sheetjs? It is the best lib ever!
I also wrote a simple formula parser if you need to evaluate some formula on nodejs server side.
OpenXML SDK for javascript
Use this.

Parse Microsoft Office files in Node.JS

I'm working on a web application where users can upload Microsoft Office Document files. Right now, our server is running Node.JS with Express.js and we're hosted on Heroku. Because of this, I don't think that I can install programs such as abiword or catdoc. I can handle the file uploads, but can't parse the contents of the document.
How can I read the contents of the doc file? The information will then be put into a database. It'd be nice to preserve basic formatting (bold, italic, underline), but not essential.
While there don't seem to be anything you can get with NPM that will do Word directly, you might be able to use a REST API to request it via another cloud service. For example Saaspose (they of the famous Aspose tools) have public API for Word, Excel, PDF, and others. They list node.js, javascript, and Heroku support on their page.
EDIT:
I see that Saaspose is now called Aspose for Cloud
Another API that claims something similar is Doxument
Office package: npm install office seems to provide at least part of the answer. I use it to read Excel files, so far have not tried any Word docs.
There doesn't seem to be any yet. See below for something that might help.
Can I read PDF or Word Docs with Node.js?
You can use mammoth to parse .docx files https://www.npmjs.com/package/mammoth
and xlsx to parse .xlsx files https://github.com/SheetJS/js-xlsx

Create database in memory from sql/csv files in Javascript

I am creating a product that as end result will/can create e.g. 10 .sql files, each being a table. The tables will contain various pre-calculated data related to each other.
My users will need to upload these to their website (php, asp, whatever) and will need to make something useful. Only problem, the users may have next to zero understanding of databases, server-side code etc. This means it must be very easy to configure.
So I think thinking upload these .sql (or CSV files, whatever) tables to server, so they are publicly available (i.e. can be retrieved like any other public URL). And then find a Javascript in-memory database engine that can load .sql database files. Does this exist?
I imagine a Javascript solution could work well if amount of data could be kept somewhat down... Otherwise I may need to look for a PHP/ASP solution as well. (Any ideas for libraries that can init in-memory databases from .sql or similar files?)
Preferably I should be able to re-distribute this Javascript library. (So users can get a complete "directory" of .sql files + example page + Javascript database engine to upload)
So to make the question clear: Anyone knows a Javascript-based in-memory database engine that can run inside browser?
If you wish to use javascript and need some 'userfriendly' bridge database, you could use json or xml, because the format are simple text files (like csv as well) for wich you can find smart small editors for your users.
More json is made for javascript parsing and has an understanding tree format, but you should load only some part of sql datas in memory, saying data buffers in xml or json, with php requested with some javascript ajax call. Php do the sql database access work and then you can output json, and with javascript, it is for user's interface, you'll be able to display them.
You can use mysql to store a database in memory:
http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html
Here's a pure JS SQL engine that stores everything in memory, https://github.com/moxley/sqittle
It flatly denies being useful for anything though, and has a limited set of supported commands (see readme on above link.
http://diveintohtml5.ep.io/storage.html might be what you are looking for.
That question seems very old. You might want to look at LokiJS now.

How to parse an excel file in JavaScript?

I am trying to write a small web tool which takes an Excel file, parses the contents and then compares the data with another dataset. Can this be easily done in JavaScript? Is there a JavaScript library which does this?
How would you load a file into JavaScript in the first place?
In addition, Excel is a proprietary format and complex enough that server side libraries with years in development (such as Apache POI) haven't yet managed to correctly 100% reverse engineer these Microsoft formats.
So I think that the answer is that you can't.
Update: That is in pure JavaScript.
Update 2: It is now possible to load files in JavaScript: https://developer.mozilla.org/en-US/docs/DOM/FileReader
In the past four years, there have been many advancements. HTML5 File API has been embraced by the major browser vendors and performance enhancements actually make it somewhat possible to parse excel files (both xls and xlsx) in the browser.
My entries in this space:
http://oss.sheetjs.com/js-xls/ (xls)
http://oss.sheetjs.com/js-xlsx/ (xlsx)
Both are pure-JS parsers
To do everything in js, you'll have to use ActiveX and probably the office web components as well. Just a suggestion, but you probably don't want to go this route; it'll be inefficient and IE/Win only. You'll be better off with a server based solution.
You will need to use ActiveX (see W3C Schools on the use of AJAX) and register the file in the hosting computers Dataconnectors (only the computer hosting the file). Unlike mentioned before, this method is not Microsoft platform dependant (for the client anyways) and you do not need to have Office components installed.
This can be done for most datafiles registered in Windows, including MDB's, and allows you as much control as you want, as you can assign different Windows Accounts for different purposes.
Like I said before, this all is serverside and has no impact on the client, apart from maybe retrieving credentials, actions and all that.
This method uses JavaScript, SQL (no, not even MSSQL, just SQL standard) and requires only that the hosting computer is running ANY Microsoft NT platform.
What Windows dataconnectors do is provide a generalised interface for various data components much like DirectX does for videocards and other peripherals. You can also use it to link an MDB (Microsoft Access) to a MySQL server and feed data live that way, which I believe is even simpler than using XLS spreadsheets...especially since you can import XLS into MDB.
Do you really need an Excel file? Why not use Excel to export the data in CSV or XML and load that?
The Excel file format is very specific to Excel's implementation. If you just need the data, use a file format that just contains the data.

Categories