read non-xml file from BaseX database - xquery

How can I read a non-XML (specifically CSV) file that is stored in a BaseX database from a query?
csv:doc() expects a URI, how do I point it to a file inside the database?

Ooh, I think I got it:
csv:parse(convert:binary-to-string(db:retrieve("db", "path/to/file.csv"), 'UTF-8')
Or is there an easier way?

Related

Trying to open ArcGIS created Dbf file in Sqlite3

I am using a GIS program called ArcGIS to create a .dbf file from shapefile data. I have tried opening the .dbf file in sqlite3. sqlite3 stated "Error: file is encrypted or is not a database". What is causing this error? Why can't I open the .dbf in sqlite3?
When I open the dbf file in Excel I have no issues.
Edit: I am new user to Stack Overflow. SO I am confused at why there no explaination for -1 Vote. What does it mean? And if I get no input into why down votes happen, how can I learn to write better questions?
Edit 2: Since getting an answer, I have researched more and understand better that dbf files are old format that has no SQL component to it. Originally I thought (wrongly) if dbf and sqlite are both databases then they must be compatible. When just starting out, basic questions to you may not be so basic to others.
A .dbf file is a dBase database file. SQLite is a different database system with a completely different database file format. SQLite clients are not made to handle .dbf files. So the behavior you see is expected.
If you really need to access this data with a SQLite client, you could use ArcGIS's Create SQLite Database tool and copy the data from the shapefile to a SQLite database.

Importing sqlite data to chrome browser

I have got a .sqlite file which has table definition and data. I want to store this data to chrom broswer and query against it. I tried query it against the physical file but it does not seem to work. Any ideas?
You have to use JavaScript and a WebSQL database. See: http://dev.w3.org/html5/webdatabase/
But importing your file is not that easy because with WebSQL you can't read an sqlite file but WebSql is the only way for storing information via SQL in Chrome.

error while reading file into sqlite3

I am a newbie to sqlite3.
I have some files which contain a .db file and also another file which contains the definition s of many tables. I try to open with notepad and see that it has create table definitions of many files.
I am trying to read them in sqlite3 in linux.
I try to use .read FILENAME after which I try to see the tables by giving .tables command.
I cant see them.
Is there a way I need to source the file or execute.
Thanks for your help in advance
I haven't done anything with SQLite in a long time, but when I did work with it I used a Firefox extension that made it easy.
Check out SQLite Manager to open the DB file:
https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
.read FILENAME already executes the sql script in the FILENAME. Check if your .db file is writable and/or if the sql contained your file is correct.

Howto speed up the Saxon doc() function?

I have a 12mb XML file which I am accessing from within an xquery. The file is loaded something like this;
let $t := doc('file:///C:/foo/bar/file12mb.xml')
The code is taking about 950ms to execute.
How can the XML document be loaded faster?
Once the xml file is loaded and parsed, the body of the xquery only takes a few milliseconds to run, so I'm trying to speed up the initial loading and parsing of the xml file which is taking the majority of the execution time.
Is there any way for Saxon to persist an xml document after it has been parsed?
Ideally I would like to persist the xml data file somehow but Saxon seems to be designed purely as an xml processor not an xml database.
Would a Schema help?
The xml file does not currently have a schema associated with it. The Saxon documentation implies that having a schema speeds up query execution but slows down the initial loading and parsing of the xml data, so I haven't tried creating a schema.
Any suggestions gratefully received.
Versions
java version "1.6.0_26"
Saxon-B version 9.1.0.8
That sounds pretty fast for parsing a 12MB file. I don't think you can optimize that, and no, Saxon is not a database.
In MarkLogic the parsing of the XML only ever happens once: during ingest. In other databases, such as Oracle, that may or may not be the case, depending on how you load it.

save the uploaded .doc file to db with html format

In my application,user can upload some doc files to the server,and I want user who do not install ms office can read these documents,so I want to convert the .doc to html and then save the html(binary stream) to oracle db.
I wonder if there is a best pratice to implement this?
Someone tell me to use the com object provoided by the office assembly,it seems that it will transfer the .doc file to a .html file,so I have to save the .html file to db and delete the temp .html file,I want to know if I can save it in db directly?
You might need to give everyone a bit more information...
I assume you're using a server side technology? Which one?
What database are you using?
The chances are if the COM object is writing it to a file, you will - like you say, just need to copy that into the DB, and delete the temp file.
IMHO - There should be nothing wrong with saving to temp file and outputting that to DB (if you could save to memory that would be even better!)

Resources