comparing python datetime to mysql datetime -


i'm complete beginner, have test mysql db set up. trying check if backup start time listed in database before 12pm on current day. time entered table using following:

update clients set backup_started=now() id=1; 

what trying is:

now = datetime.datetime.now() today12am = now.replace(hour=0, minute=0, second =0,) dbu.cursor.execute('select id, company_name, backup_started,\ backup_finished clients backup_started>' + today12am) data = dbu.cursor.fetchone() print (data) 

i understand trying compare datetime.datetime string , having problems. question best way accomplish this?

error:

typeerror: cannot concatenate 'str' , 'datetime.datetime' objects 

make query parameterized:

dbu.cursor.execute("""     select          id, company_name, backup_started, backup_finished               clients               backup_started > %s""", (today12pm, )) 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -