I want to take some action based on comparing two dates. Date 1 is stored in a python variable. Date 2 is retrieved from the database in the select statement. For example I want to retrieve some records from the database where the associated date in the record (in form of the timestamp) is later than the date defined by the python variable. Preferably, I would like the comparison to be in readable date format rather than in timestamps.
I am a beginner with python.
----edit ----- Sorry for being ambiguous. Here's what I am trying to do:
import MySQLdb as mdb from datetime import datetime from datetime import date import time
conn = mdb.connect('localhost','root','root','my_db') cur = conn.cursor()
right_now = date.today()// python date
this is the part which I want to figure out
The database has a table which has timestamp. I want to compare that timestamp with this date and then retrieve records based on that comparison. For example I want to retrieve all records for which timestamp is above this date cur.execute("SELECT created from node WHERE timestamp > right_now") results = cur.fetchall() for row in results: print row