I have a task to copy data from one db table to another db table using psycopg2 library in python language.
Now after fetching a row from first db I have to insert the row into the second db table, but the problem I face is that I need to format the query and insert the value for date column from a variable which may or may not have a date value, so my query is like the following:
cur.execute("""update table_name set column1 = '%s', column2 = '%s',column_date = '%s'""" % (value1, value2, value_date))
will now the value_date may be a date or a None value, so how to I convert this None value to sql null or something so that it can be stored in the date column.
Note: considering the value1, value2 and value_date are variables containing values.