can I query a mysql database while data is being loaded from a csv file?

It is taking too long, and I don’t have a way of knowing if it is going to be loaded as expected after it finishes. Can I query the table to at least make sure that the data is being loaded as expected ? is there a way of seeing some rows while the load is working?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If we assume you are using the LOAD DATA INFILE statement to do the bulk load, then the answer is no, the bulk-load executes atomically. This means no other session can see the result of the bulk-load until it is complete. If it fails for some reason, the entire dataset is rolled back.

If you want to see incremental progress, you would need to use some client that reads the CSV file and inserts individual rows (or at least subsets of rows) and commits the inserts at intervals.

Or you could use LOAD DATA INFILE if you split your CSV input file into multiple smaller files, so you can load them in batches. If you just want to test if the loading is done properly, you should start with a much smaller file and load that.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x