我正在尝试通过psycopg2运行查询,该查询根据今天的日期选择一行数据。我如何使用%来完成此任务?
import sys
from datetime import datetime as dt
import psycopg2
hostname = '###'
username = '###'
password = '###'
database = '###'
# Run psql query and print results
def doQuery(conn):
cur = conn.cursor()
cur.execute( "select * from getsimplebookevents_psx(%s,'{CSCO}')
order by tstamp desc limit 1;")
for symbol in cur.fetchall():
print symbol