Psycopg2查询返回今天的日期

时间:2017-12-11 21:12:09

标签: python postgresql psycopg2

我正在尝试通过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

0 个答案:

没有答案