I have got a table called ‘TEST’ and I have got a column called ‘UPLOAD_TIME’ what is a varchar(100) and the format is the next :
How can I query data from this table if i want to resemble my ‘UPLOAD_TIME’ column with the actual date now, and select data where year-month-day are equal with my data?
connection = MySQLdb.connect(host='localhost', user='admin', passwd='****', db='database1', use_unicode=True, charset="utf8") cursor = connection.cursor() query = """ select 'column1', 'column2', 'column3', 'column4', 'column5', 'column6', 'UPLOAD_TIME', 'ID' union all select `column1`, `column2`, `column3`, `column4`, `column5`, `column6`, `UPLOAD_TIME`, `ID` from TEST into outfile '/tmp/test.csv' fields terminated by ';' enclosed by '"' lines terminated by 'n'; """ cursor.execute(query) connection.commit() cursor.close()
- WHERE datetime =’2017-11-14′ is not an option for me, I want to resemble always to the actual date.
This should work.