How do I pass a variable(Date) as a parameter in python into SQL? -
could please guide me how can pass variable(date) parameter below sql (postgre sql database) in python script ?
last_execution_date = datetime.datetime.now().strftime("%y-%m-%d")
the query:
select distinct researcherid, username, firstname, lastname, researcher r inner join principals p on p.researcherid = r.researcherid r.lastmodifieddate > 'last_execution_date'
i need pass last_execution_date
parameter above sql statement. please tell me correct syntax? not quite sure whether possible pass outside variable parameter because sql statement runs on database , returns data.
try like:
say:
last_execution_date = datetime.datetime.now()<br>
then,
cursor.execute('select distinct researcherid , username, firstname, lastname,from researcher r inner join principals p on p.researcherid = r.researcherid r.lastmodifieddate > %s',last_execution_date)
Comments
Post a Comment