What I want to do is transfer the "12/26/17 14:30" in txt to "2017-12-26 14:30:00 " in MySQL
I've already tried this Importing a CSV to MySQL with different date format0
So my code looks like this
create_tb_str = r'''DROP TABLE IF EXISTS TABLENAME;
CREATE TABLE TABLENAME (
Datetime DATETIME,
Open float(8,3),
High float(8,3),
Low float(8,3),
Close float(8,3),
Volume INT,
PRIMARY KEY (Datetime)
);'''
insert_tb_str = r''' LOAD DATA LOCAL INFILE 'FILENAME'
INTO TABLE TABLENAME FIELDS TERMINATED BY '\t\t'
ENCLOSED BY '"' LINES
TERMINATED BY '\n'
(@time, open, high, low, close, @dummy, volume);
SET Datetime = STR_TO_DATE(@time,'%y-%m-%d %H:%i:%S');
'''
However, after I generate the .sql and try to import to my db, this is the result I get, the terminal can not recognize my table's column name.
$:~/Downloads/bartest$ mysql -u root -p bar -A < bartest.sql
Enter password:
ERROR 1193 (HY000) at line 21: Unknown system variable 'Datetime'
Any suggestion?