load-data-infile

How do I import CSV file into a MySQL table?

你离开我真会死。 提交于 2021-02-11 14:25:22
问题 I have an unnormalized events-diary CSV from a client that I'm trying to load into a MySQL table so that I can refactor into a sane format. I created a table called 'CSVImport' that has one field for every column of the CSV file. The CSV contains 99 columns , so this was a hard enough task in itself: CREATE TABLE 'CSVImport' (id INT); ALTER TABLE CSVImport ADD COLUMN Title VARCHAR(256); ALTER TABLE CSVImport ADD COLUMN Company VARCHAR(256); ALTER TABLE CSVImport ADD COLUMN NumTickets VARCHAR

Improve performance of mysql LOAD DATA / mysqlimport?

不羁的心 提交于 2021-01-28 02:30:41
问题 I'm batching CSV 15GB (30mio rows) into a mysql-8 database. Problem: the task takes about 20min, with approxy throughput of 15-20 MB/s. While the harddrive is capable of transfering files with 150 MB/s. I have a RAM disk of 20GB, which holds my csv. Import as follows: mysqlimport --user="root" --password="pass" --local --use-threads=8 mytable /tmp/mydata.csv This uses LOAD DATA under the hood. My target table does not have any indexes, but approx 100 columns (I cannot change this). What is

Bash Script for Load Data Infile MySQL

老子叫甜甜 提交于 2020-12-04 02:25:28
问题 So i'm trying to create a script that I can run that will do a batch import of csv files into a table. I'm having trouble getting the script to work. Here is the script i'm running: #!/bin/bash for f in *.csv do "/opt/lampp/bin/mysql -e use test -e LOAD DATA LOCAL INFILE ("$f") INTO TABLE temp_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES (DATE, TIME, SITE_NAME, SITE_IP, TOTAL_TALKTIME, EDGE_UL_BYTES, EDGE_DL_BYTES);" done When I run the

MySQL: Enable LOAD DATA LOCAL INFILE reset

若如初见. 提交于 2020-05-31 04:18:27
问题 After reading several answers on here, I finally figured out why my .csv file wasn't loading in through the command prompt. I had to enable load data local infile. Once I did that, I read the global variables and they were on. I was able to load the data then. However, after closing the command prompt, I reopened it and while the variable was still reading as ON, it wouldn't allow me to import another .csv file. Do i need to turn local infile off and back on for it to work again EDIT: this is

mysql LOAD DATA INFILE with auto-increment primary key

假如想象 提交于 2020-03-18 03:31:39
问题 I am trying to load a data file into mysql table using "LOAD DATA LOCAL INFILE 'filename' INTO TABLE 'tablename'". The problem is the source data file contains data of every fields but the primary key is missing ('id' column). I add a unique id field while I create the database but now I need to import the data into the table starting from the next field and auto increment the id field while importing. def create_table(): cursor.execute (""" CREATE TABLE variants ( id integer(10) auto

How to improve performance of a mysql LOAD XML LOCAL INFILE table import?

陌路散爱 提交于 2020-02-08 09:45:10
问题 For a mysql database, I have some XML dump files. One table import file for a pricing table looks like this: <database> <table> <row> <id>5954017</id> <foo>narf</foo> <bar_id>1377</bar_id> <price_single>800.00</price_single> <price_double>1500.00</price_double> <price_triple>2000.00</price_triple> <price_quad>1900.00</price_quad> <currency>USD</currency> </row> ... </table> </database> It has $ xmllint --xpath "count(//row)" import.xml 223198 rows and its size is: du -h import.xml 69M import

LOAD DATA INFILE error 1064

烈酒焚心 提交于 2020-02-03 09:46:49
问题 I am running this MySQL command: LOAD DATA LOCAL INFILE 'books.csv' INTO TABLE BOOK (Book_id, @dummy, Title, Publisher_name, @dummy, @dummy) FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n' IGNORE 1 LINES; I am getting an error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n' IGNORE 1 LINES' at line 3 What am I doing wrong here?

LOAD DATA INFILE error 1064

六月ゝ 毕业季﹏ 提交于 2020-02-03 09:46:30
问题 I am running this MySQL command: LOAD DATA LOCAL INFILE 'books.csv' INTO TABLE BOOK (Book_id, @dummy, Title, Publisher_name, @dummy, @dummy) FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n' IGNORE 1 LINES; I am getting an error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n' IGNORE 1 LINES' at line 3 What am I doing wrong here?

How to solve Error 1148 from MySql workbench and not cmd?

可紊 提交于 2020-02-02 11:37:47
问题 I am running the following statement to import data: LOAD DATA LOCAL INFILE 'C:\\Users\\talkohavy\\Desktop\\MySQL_data\\categories.csv' INTO TABLE BI_EX_OLTP.categories FIELDS TERMINATED BY ',' IGNORE 1 LINES; And then I get this error: error code 1148. the used command is not allowed with this mysql version. How can I enable loading local data using the MySql Workbench and not the cmd ? 回答1: I believe this is an issue with the new versions of Workbench (having the same issue in Workbench 8.0

No SQL Query results after successful CSV import in mysql using LOAD DATA LOCAL INFILE

岁酱吖の 提交于 2020-01-24 14:20:36
问题 I am facing a strange problem after successfully importing the contents of a .csv file in mysql db. The data from the csv file is imported into the db table successfully but no query results are returned if i run any SQL query with a Condition on on the table. I am able to run the query : select * from mst_question but no results are returned if a condition is specified and the condition is met select * from mst_question where qtype='single' The table is having rows where the column qtype