Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何按月份名称查询sqlalchemy_Python_Sqlalchemy_Flask_Flask Sqlalchemy - Fatal编程技术网

Python 如何按月份名称查询sqlalchemy

Python 如何按月份名称查询sqlalchemy,python,sqlalchemy,flask,flask-sqlalchemy,Python,Sqlalchemy,Flask,Flask Sqlalchemy,我试过这个 db_session.query(PaymentsMade).filter(func.strftime('%B', PaymentsMade.created_at) == "August").all() 但是我得到了这个错误 (ProgrammingError) function strftime(unknown, timestamp without time zone) does not exist LINE 3: WHERE strftime('%B', paymentsmad

我试过这个

db_session.query(PaymentsMade).filter(func.strftime('%B', PaymentsMade.created_at) == "August").all()
但是我得到了这个错误

(ProgrammingError) function strftime(unknown, timestamp without time zone) does not exist
LINE 3: WHERE strftime('%B', paymentsmade.created_at) = 'August'
          ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

我正在保存在=datetime.utcnow()创建的日期,您想调用PostgresSQL函数,而不是Python
datetime
函数
strftime

db_session.query(PaymentsMade) \
    .filter(func.to_char(PaymentsMade.created_at, "FMMonth") == "August")

您希望调用PostgresSQL函数,而不是Python
datetime
函数
strftime

db_session.query(PaymentsMade) \
    .filter(func.to_char(PaymentsMade.created_at, "FMMonth") == "August")

您使用的是什么数据库?postgres感谢您的回复您使用的是什么数据库?postgres感谢您的回复完美:)以及我如何查询月份列表,例如“六月、七月、八月”@sunny-您应该能够将
)=“八月”
更改为
)。在(“六月”、“七月”、“八月”)
中,并让它工作(但我不是100%确定)。完美:)我如何查询月份列表,比如“六月、七月、八月”@sunny-你应该能够将
)==“八月”
更改为
)。在(“六月”、“七月”、“八月”)
中,让它工作(但我不是100%确定)。