I am trying to upload a XML file to MySQl server.
I have a React web app, I am using Axios and NodeJS.
I was using the follwing statement to import the xml file to the product table directly from the workbench
LOAD XML INFILE "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/products.xml" INTO TABLE product ROWS IDENTIFIED BY <Product>;
It worked fine.
Now I want to have a button that will upload anew xml file and replace the existing data in the table.
What I tried so far is using the HTML input file element, grabing the file from the event.target.files[0] and sending the file object to the server with a POST request.
I am not realy sure how to go from here I cant find a statement that can import the data out of the file object and imoprt it into the sql table.
any ideas? what is the best way to go about it?
I figured out my problem, my site was deployed to Heroku.
Apparently the clearDB, Heroku's add-on sql database, does not allow the use of LOAD XML INFILE / LOAD DATA INFILE as said here - https://getsatisfaction.com/cleardb/topics/load-data-local-infile.
What I ended up doing was converting the xml file to JS object.
That solution presented a new problem, my xml file was around 3MB summed up to over 12000 rows to insert to the database.
MySQL does not allow inserting more then a 1000 rows in a single query.
I had to split the object to several chuncks and loop through them uploading each one by it self.
This process takes some time to execute and I am sure there are better ways of doing it.
If anyone can shed some light on how best to go about it or provide an alternative I would apprreciate it.
Related
I am using jquery.datatable.editable and I want this datatable to get the main data from a simple CSV-file stored on the webserver. This is shown possible with CSV to HTML Table.
When I edit a cell inside jquery.datatable.editable I want it to update the CSV-file stored on my webserver. How can I do this?
I also checked vscode-edit-csv and love the layout as an editing interface but it only seams that it opens the file from a local stored file and not from the server...
(Some people use mySQL but I want to use a flat file (CSV) instead for syncing reasons.)
What have I tried
As you can see here, this is my configuration on trying to save the output data from query to s3 as CSV. The query was successful (from what I've check on the logs) but it seems that it doesn't create any file on the s3 output location.
Main Problem
I know about the CopyActivity and I tried that successfully, but the problem is that my query is too long that it reaches the limit 10240. From what I've searched, you can save the SQL file on S3 then use SQL Activity to add Script URI and point it on the SQL file saved on S3. But it seems that only CopyActivity can create and save CSV as an output on S3.
Questions
Is there any work around on long query to still use Copy Activity?
Is there a way to use the SQL Activity and create CSV file on S3?
Is it breaking down the SQL query will be the only solution?
I am setting up a application with Django/ExpressJS(prototyping) and vueJS and MYSQL.
One goal is generate .txt file from data store in row. Each row will have one .txt file and user can download them via button click.
Quit not sure how to do that, Can use SQL query but hope there is some way via Django.
I am new with Django, experience in ExpressJS.
I am in the process of starting a project and i want to understand the best way to automate the creation of a text/CSV file containing the result of a request. And each time the database is updated, i want that file to be updated too. I'm using LibreOffice Base.
Hay,
LibreOffice Base is not going to help you in this case as it is just a GUI tool for querying a Connected DB.
I would look at getting your backend to append to a log/CSV file every time it receives a request and successfully obtains/manipulates data in the Database.
Busy building a website for a client using classic ASP (It will reside on an old server) which is going to be used internally only.
The admin is able to view a paginated table of data and export this to CSV. This works fine when I save the CSV data to a CSV file but I have now been asked to try avoid the creation of the file if possibly and create the CSV in memory without the need for a file.
I have my doubts that this is possible but might be completely wrong. Is there anyway to send the CSV data to the browser such that it will open in Excel rather than having to create a CSV file and link to it as I am currently doing ?
TIA
John
Response.ContentType = "text/csv" will help you here. In the past I've paired that with a rewrite rule so that the URL is something like foo.com/example.csv but there are plenty of other ideas to be found in the following question: Response Content type as CSV