I wanted to fetch a record from database which is having the datetime
field a part of primary key. I am querying from python
using mysqldb package
which is resulting in error
Invalid datetime format
wherein the same query is working fine when executed through command line and mysql workbench.
My code looks like this.
def get_all_list(table_name, modify_dt, params):
cursr = connections['default'].cursor()
stmt = 'select * from ' + table_name + ' where ' + params
cursr.execute(stmt)
data = cursr.fetchall()
the params is the string which contains my primary key value.
for instance
params is "join_date = '2016-09-08 00:00:00+00:00'"
my final query looks similiar to this
select * from employee where join_date = '2016-09-08 00:00:00+00:00'
When executed, the same is providing result in mysql workbench while when executed through my program , I am getting error as
Incorrect datetime value: '2016-09-08 00:00:00+00:00' for column 'join_date' at row 1