0

i have created a column for date using workbench now i have to update all the values of that column to current date either using sql query or using python code

mydb = mysql.connector.connect(host="localhost", user="root", 
password="afif123", db="library")
mycursor = mydb.cursor()
fill = '''UPDATE issued_book SET Today = current_date()'''
mycursor.execute(fill)
#or
today = datetime.datetime.now()
fill = '''UPDATE issued_book SET Today = %s'''
mycursor.execute(fill, [today])

any of above two attempt doesn't helping

i have kept datatype of date column as DATETIME()

1 Answers1

0

To do it in mysql, just modify your first query a bit...

update issued_book set today = now()

instead of current_date(), which is not a mysql function.

bitbangs
  • 506
  • 3
  • 6